
/* ========= Toast 队列 ========= */
.toast-stack[data-v-9eda6573] {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px; max-width: 380px;
  pointer-events: none;
}
.toast[data-v-9eda6573] {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 10px;
  background: var(--bg-card, #fff); border: 1px solid var(--border, #e5e5e5);
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  font-size: 14px; line-height: 1.5;
}
.toast-icon[data-v-9eda6573] { font-size: 18px; margin-top: 2px; flex-shrink: 0;
}
.toast-body[data-v-9eda6573] { flex: 1; min-width: 0;
}
.toast-title[data-v-9eda6573] { font-weight: 600; font-size: 13px; margin-bottom: 2px;
}
.toast-msg[data-v-9eda6573] { white-space: pre-wrap; word-break: break-word;
}
.toast-close[data-v-9eda6573] {
  background: none; border: none; cursor: pointer;
  color: var(--text-dim, #999); padding: 0 2px; font-size: 12px;
}
.toast-success .toast-icon[data-v-9eda6573] { color: #27ae60;
}
.toast-error   .toast-icon[data-v-9eda6573] { color: #e74c3c;
}
.toast-warning .toast-icon[data-v-9eda6573] { color: #f39c12;
}
.toast-info    .toast-icon[data-v-9eda6573] { color: #3498db;
}
.toast-success[data-v-9eda6573] { border-left: 3px solid #27ae60;
}
.toast-error[data-v-9eda6573]   { border-left: 3px solid #e74c3c;
}
.toast-warning[data-v-9eda6573] { border-left: 3px solid #f39c12;
}
.toast-info[data-v-9eda6573]    { border-left: 3px solid #3498db;
}

/* transition */
.toast-enter-from[data-v-9eda6573] { opacity: 0; transform: translateX(30px);
}
.toast-leave-to[data-v-9eda6573]   { opacity: 0; transform: translateX(30px);
}
.toast-move[data-v-9eda6573]       { transition: transform 0.25s;
}

/* ========= Confirm 对话框 ========= */
.confirm-mask[data-v-9eda6573] {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 10000;
}
.confirm-box[data-v-9eda6573] {
  background: var(--bg-card, #fff);
  border-radius: 12px; padding: 24px; min-width: 340px; max-width: 480px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.confirm-title[data-v-9eda6573] { font-size: 16px; font-weight: 600; margin-bottom: 12px;
}
.confirm-message[data-v-9eda6573] { font-size: 14px; line-height: 1.6; color: var(--text-dim, #555); margin-bottom: 20px; white-space: pre-wrap;
}
.confirm-btns[data-v-9eda6573] { display: flex; justify-content: flex-end; gap: 10px;
}
.fade-enter-from[data-v-9eda6573], .fade-leave-to[data-v-9eda6573] { opacity: 0;
}

.course-switch select[data-v-1d9f54d8] {
  padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--border, #ddd);
  background: var(--bg-card, #fff);
  font-size: 13px; cursor: pointer;
}
.settings-btn[data-v-1d9f54d8] {
  padding: 6px 10px;
  font-size: 15px;
}
/* style.css — 书本风（象牙黄纸 + 墨色字） */

:root {
  /* ===== 双轴缩放因子（JS 动态写入）=====
     字体缩放影响所有 font-size；图形缩放影响图标、图片、按钮大小
     全部组件层用 calc(基准 * var(--scale-font/img)) 引用 */
  --scale-font: 1;
  --scale-img: 1;

  /* 象牙黄纸色系，不做纯白（#ffffff 太硬） */
  --bg: #f9f6ef; /* 主背景：象牙米白 */
  --bg-elev: #f2ede1; /* 卡片：略深一档的米 */
  --bg-elev2: #ebe5d5; /* 输入框 / 次级背景 */
  --bg-hover: #e4ddc9; /* hover 叠色 */
  --border: #d8d2c4; /* 主边框：淡灰褐色 */
  --border-soft: #e6e0d3; /* 浅分隔线 */
  /* 墨色字系，不用纯黑（#000000 刺眼） */
  --text: #2a2418; /* 深棕墨色 */
  --text-dim: #6b6050; /* 次要文字 */
  --text-faint: #9a8f7a; /* 弱化文字 */
  /* 书脊靛蓝 — 有书卷气但不过分 */
  --accent: #2c5282;
  --accent-dim: #2b4c74;
  --accent-bg: rgba(44, 82, 130, 0.1);
  --accent-bd: rgba(44, 82, 130, 0.28);
  /* 状态色低饱和，浅色背景上深字 */
  --success: #1e7e46;
  --success-bg: rgba(30, 126, 70, 0.1);
  --success-bd: rgba(30, 126, 70, 0.3);
  --danger: #c0392b;
  --danger-bg: rgba(192, 57, 43, 0.1);
  --danger-bd: rgba(192, 57, 43, 0.3);
  --warn: #b57a1a;
  --warn-bg: rgba(181, 122, 26, 0.1);
  --warn-bd: rgba(181, 122, 26, 0.3);
  /* 代码块：浅灰 + 深字，模拟纸质铅印 */
  --code-bg: #f5f1e6;
  /* 圆角不变 */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 8px;
}

/* ===== 基础 ===== */
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  font-family:
    "Inter", -apple-system, "SF Pro Text", "Segoe UI Variable", "Microsoft YaHei", "PingFang SC",
    sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01", "ss03";
  font-size: calc(18px * var(--scale-font));
  line-height: 1.55;
}
.fa-solid,
.fa-regular,
.fa-brands {
  display: inline-block;
  vertical-align: -2px;
  margin-right: 4px;
  font-size: 0.9em;
}
.fa-solid:last-child,
.fa-regular:last-child,
.fa-brands:last-child {
  margin-right: 0;
}

/* ===== Top bar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 12px 24px;
  gap: 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .zoom-group {
  flex-shrink: 0;
}
.topbar .clock {
  flex-shrink: 0;
}
.topbar .brand {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand {
  font-size: calc(16px * var(--scale-font));
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text-dim);
}
.clock,
.timer {
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: clamp(15px, 0.65vw + 9px, 22px);
  padding: 3px 8px;
  background: var(--bg-elev);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  border: 1px solid var(--border);
  font-weight: 500;
}
.question-timer {
  color: var(--text);
  border-color: var(--accent-bd);
}
.question-timer.warn {
  color: var(--danger);
  border-color: var(--danger-bd);
  background: var(--danger-bg);
  animation: pulse-timer 0.5s ease 3;
}
@keyframes pulse-timer {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}
/* 字号缩放按钮组 —— 书本风的 tiny 工具 */
/* 字号 & 图形 缩放控件：两个 zoom-group 并排 + reset */
.topbar > .zoom-group,
.topbar > .zoom-reset {
  margin-left: auto;
}
.topbar > .zoom-group + .zoom-group {
  margin-left: 6px;
}
.topbar > .zoom-reset {
  margin-left: 6px;
}

.zoom-group {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.zoom-group button {
  width: 26px;
  height: 24px;
  padding: 0;
  border: none;
  background: var(--bg-elev);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  line-height: 1;
  transition:
    background 0.12s,
    color 0.12s;
  border-right: 1px solid var(--border);
}
.zoom-group button:last-child {
  border-right: none;
}
.zoom-group button:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}
.zoom-group button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.zoom-group .zoom-label {
  font-size: 10px;
  color: var(--text-faint);
  font-family: "JetBrains Mono", monospace;
  padding: 0 6px;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  height: 24px;
  line-height: 24px;
}
.zoom-group .zoom-label:first-child {
  color: var(--accent);
  font-weight: 600;
  border-right: 1px solid var(--border);
}
.zoom-group .zoom-label:last-child {
  border-right: none;
}

/* 重置按钮 */
.zoom-reset {
  width: 26px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1;
  transition:
    background 0.12s,
    color 0.12s;
}
.zoom-reset:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

/* ===== 首页布局 ===== */
#app {
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
}
.hero {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-elev);
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.stat-card.big {
  grid-column: span 2;
}
.hero > :last-child:nth-child(4n + 1) {
  grid-column: span 4;
}
.hero > :last-child:nth-child(4n + 2) {
  grid-column: span 2;
}
.hero > :last-child:nth-child(4n + 3) {
  grid-column: span 3;
}
.stat-num {
  font-size: calc(28px * var(--scale-font));
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.5px;
}
.stat-num span {
  font-size: calc(18px * var(--scale-font));
  color: var(--text-dim);
  font-weight: 500;
}
.stat-label {
  color: var(--text-dim);
  margin-top: 4px;
  font-size: calc(14px * var(--scale-font));
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.progress {
  margin-top: 8px;
  height: 5px;
  background: var(--bg-elev2);
  border-radius: 3px;
  overflow: hidden;
}
.progress .bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.4s ease;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card h3 {
  margin: 0 0 12px 0;
  font-size: calc(15px * var(--scale-font));
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.type-list .type-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: calc(16px * var(--scale-font));
}
.type-list .type-row:last-child {
  border-bottom: 0;
}
.muted {
  color: var(--text-dim);
}

/* ===== 表格 ===== */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: calc(16px * var(--scale-font));
}
.table th,
.table td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
}
.table th {
  background: transparent;
  color: var(--text-faint);
  font-weight: 500;
  font-size: calc(14px * var(--scale-font));
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.table tbody tr:hover {
  background: var(--bg-elev);
}
/* 仅表格里的题干预览列做单行省略（.q-title 同时是练习/结果页题干类名，不能全局省略） */
.history-table .q-title,
.due-scroll .q-title {
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.due-row {
  cursor: pointer;
}
.due-row:hover {
  background: var(--bg-hover);
}
/* 历史行着色 */
.due-row.row-right {
  border-left: 3px solid var(--success, #3fb950);
}
.due-row.row-right td:first-child {
  background: rgba(63, 185, 80, 0.08);
}
.due-row.row-wrong {
  border-left: 3px solid var(--danger, #f85149);
}
.due-row.row-wrong td:first-child {
  background: rgba(248, 81, 73, 0.08);
}
.due-row:hover {
  background: var(--bg-hover);
}
/* 历史页筛选头 */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.history-stats {
  font-size: calc(14px * var(--scale-font));
  color: var(--text-dim);
  display: flex;
  gap: 6px;
  align-items: center;
}
.dot-sep {
  opacity: 0.4;
}
.tag-right {
  color: var(--success, #3fb950);
  font-weight: 600;
}
.tag-wrong {
  color: var(--danger, #f85149);
  font-weight: 600;
}
.tag-right-sm {
  display: inline-block;
  color: var(--success, #3fb950);
  font-size: 12px;
  margin-right: 6px;
}
.tag-wrong-sm {
  display: inline-block;
  color: var(--danger, #f85149);
  font-size: 12px;
}
.filter-tabs {
  display: flex;
  gap: 4px;
}
.tab-btn {
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  transition: all 0.15s;
}
.tab-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}
.tab-btn.active {
  background: var(--accent, #2c5282);
  color: #fff;
  border-color: var(--accent);
}
.count-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.12);
  font-size: 11px;
}
.level-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.06);
  font-size: 12px;
  font-family: "JetBrains Mono", monospace;
}
/* mini 按钮（操作列） */
.mini-btn {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  transition: all 0.12s;
  margin-right: 4px;
}
.mini-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--bg-hover);
}
.mini-btn.primary {
  color: var(--accent, #2c5282);
  border-color: currentColor;
}
.mini-btn.primary:hover {
  background: rgba(44, 82, 130, 0.1);
}
.qid-cell {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
}
.due-scroll {
  max-height: 420px;
  overflow-y: auto;
  border-top: 1px solid var(--border-soft);
}
.due-scroll table {
  margin-top: 0;
}
.due-scroll thead th {
  position: sticky;
  top: 0;
  background: var(--bg-elev);
  z-index: 1;
}

/* ===== 章节网格 ===== */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.chapter-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition:
    background 0.12s ease,
    border-color 0.12s ease;
}
.chapter-card:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}
.ch-id {
  font-family: "JetBrains Mono", monospace;
  color: var(--text-faint);
  font-size: calc(14px * var(--scale-font));
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}
.ch-name {
  font-weight: 600;
  font-size: calc(16px * var(--scale-font));
  margin-bottom: 4px;
}
.ch-count {
  color: var(--text-dim);
  font-size: calc(15px * var(--scale-font));
}
.ch-count-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}
.ch-done {
  color: var(--accent);
  font-weight: 700;
}
.ch-acc {
  font-size: 12px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--bg-elev2);
  color: var(--text-dim);
}
.ch-acc.acc-good {
  background: rgba(63, 185, 80, 0.12);
  color: #2da44e;
}
.ch-acc.acc-mid {
  background: rgba(210, 153, 34, 0.12);
  color: #b08800;
}
.ch-acc.acc-bad {
  background: rgba(248, 81, 73, 0.12);
  color: #da3633;
}
.ch-progress {
  margin-top: 8px;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.ch-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ===== Buttons ===== */
.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: calc(16px * var(--scale-font));
  font-weight: 500;
  transition:
    background 0.12s,
    border-color 0.12s,
    color 0.12s;
  line-height: 1.4;
}
.btn:hover:not(:disabled) {
  background: var(--bg-hover);
}
.btn:active:not(:disabled) {
  background: var(--bg-elev2);
}
.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover:not(:disabled) {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
}
.btn.danger {
  background: var(--danger-bg);
  border-color: var(--danger-bd);
  color: var(--danger);
}
.btn.danger:hover:not(:disabled) {
  background: rgba(248, 81, 73, 0.2);
}
.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
}
.btn.ghost:hover:not(:disabled) {
  color: var(--text);
  background: var(--bg-hover);
}

/* ===== Badges ===== */
.badge-warn {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--warn-bd);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: calc(14px * var(--scale-font));
  font-weight: 500;
  margin-left: 6px;
}
.badge-ok {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-bd);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: calc(14px * var(--scale-font));
  font-weight: 500;
  margin-left: 6px;
}

/* ===== 练习模式 ===== */
.practice-wrap {
  max-width: 900px;
  margin: 0 auto;
}
.progress-bar {
  position: relative;
  height: 4px;
  background: var(--bg-elev2);
  border-radius: 2px;
  margin-bottom: 20px;
}
.progress-bar .fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}
.progress-bar span {
  position: absolute;
  right: 0;
  top: -20px;
  font-size: calc(14px * var(--scale-font));
  color: var(--text-dim);
  letter-spacing: 0.3px;
}
/* 连击等级徽章（进度条左侧） */
.progress-bar .streak-badge {
  right: auto;
  left: 0;
  font-size: calc(12px * var(--scale-font));
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.progress-bar .streak-badge i {
  font-size: 0.9em;
}
.progress-bar .streak-badge.streak-hot {
  color: #d97706;
}
.progress-bar .streak-badge .streak-lv {
  font-style: normal;
  font-weight: 600;
  padding: 0 6px;
  border-radius: 8px;
  background: var(--bg-elev2);
  color: var(--text-dim);
  font-size: 0.92em;
}
.progress-bar .streak-badge.streak-up .streak-lv {
  background: rgba(217, 119, 6, 0.14);
  color: #b45309;
}
/* 正确率徽章 */
.progress-bar .accuracy-badge {
  position: absolute;
  right: auto;
  left: 50%;
  transform: translateX(-50%);
  font-size: calc(13px * var(--scale-font));
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 12px;
  background: var(--bg-elev2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.progress-bar .accuracy-badge i {
  font-size: 0.85em;
}
.progress-bar .accuracy-badge.acc-good {
  background: rgba(63, 185, 80, 0.12);
  color: #2da44e;
  border-color: rgba(63, 185, 80, 0.3);
}
.progress-bar .accuracy-badge.acc-mid {
  background: rgba(210, 153, 34, 0.12);
  color: #b08800;
  border-color: rgba(210, 153, 34, 0.3);
}
.progress-bar .accuracy-badge.acc-bad {
  background: rgba(248, 81, 73, 0.12);
  color: #da3633;
  border-color: rgba(248, 81, 73, 0.3);
}

/* 复习题 chip（题干元信息行） */
.review-chip {
  font-size: calc(12px * var(--scale-font));
  font-weight: 600;
  color: #7c3aed;
  background: rgba(124, 58, 237, 0.1);
  border: 1px solid rgba(124, 58, 237, 0.25);
  padding: 1px 8px;
  border-radius: 9px;
}
.question-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
}
.q-title {
  font-size: calc(19px * var(--scale-font));
  font-weight: 500;
  line-height: 1.7;
  margin-bottom: 14px;
  overflow-wrap: anywhere;
}
/* 题干里裸露 C 代码块自动包裹后的样式 */
.q-title pre.q-code-c,
pre.q-code-c {
  background: var(--code-bg, #f5f1e6);
  border: 1px solid var(--border, #d8d2c4);
  border-left: 3px solid var(--accent, #2c5282);
  border-radius: var(--radius-sm, 4px);
  padding: 12px 16px;
  margin: 10px 0;
  overflow-x: auto;
  font-family: "JetBrains Mono", Consolas, "Courier New", monospace;
  font-size: calc(13px * var(--scale-font));
  line-height: 1.55;
  color: var(--text, #2a2418);
  white-space: pre;
  tab-size: 2;
}
.q-title pre.q-code-c code,
pre.q-code-c code {
  background: transparent;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
}
/* ===== C 代码语法高亮（@lezer classHighlighter 输出 tok-* 类）=====
   颜色与 CodeEditor.vue 的 weilaiTheme 完全对齐，
   让只读代码块和 Playground 编辑器视觉一致 */
pre.q-code-c .tok-keyword {
  color: #2c5282;
  font-weight: 600;
} /* if/for/return/switch */
pre.q-code-c .tok-typeName {
  color: #744210;
} /* int/char/void/struct */
pre.q-code-c .tok-string,
pre.q-code-c .tok-string2 {
  color: #276749;
} /* "..." / <stdio.h> / \n */
pre.q-code-c .tok-number {
  color: #c05621;
} /* 123 / 0x1F */
pre.q-code-c .tok-comment {
  color: #8c7853;
  font-style: italic;
} /* 行注释与块注释 */
pre.q-code-c .tok-variableName {
  color: #2a2418;
} /* 普通变量 */
pre.q-code-c .tok-propertyName {
  color: #2a2418;
}
pre.q-code-c .tok-definition {
  color: #2a4365;
  font-weight: 600;
} /* main 等定义处函数名 */
pre.q-code-c .tok-macroName {
  color: #2a4365;
  font-weight: 600;
} /* #define 的宏名 */
pre.q-code-c .tok-operator {
  color: #9b2c2c;
  font-weight: 500;
} /* + - * & = == */
pre.q-code-c .tok-punctuation {
  color: #6b6050;
} /* ; { } ( ) , */
pre.q-code-c .tok-meta {
  color: #744210;
  font-weight: 600;
} /* #include 等预处理指令 */
pre.q-code-c .tok-atom,
pre.q-code-c .tok-bool {
  color: #c05621;
  font-weight: 600;
}
pre.q-code-c .tok-labelName {
  color: #744210;
}
pre.q-code-c .tok-invalid {
  color: #c0392b;
  text-decoration: underline wavy #c0392b;
}

/* ===== 散文考点术语高亮（题干/选项/解析统一管线）=====
   靛蓝浅底 = 普通考点；红底 = 危险/易错概念（野指针/越界/溢出…） */
.q-term {
  color: var(--accent);
  background: var(--accent-bg);
  border-radius: 3px;
  padding: 0 4px;
  font-weight: 500;
  white-space: nowrap;
}
.q-term.q-term-danger {
  color: var(--danger);
  background: var(--danger-bg);
  font-weight: 600;
}
.q-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: calc(14px * var(--scale-font));
  color: var(--text-faint);
  margin-bottom: 16px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  align-items: center;
}
.q-meta span {
  font-weight: 500;
}
/* 答题音效开关（q-meta 行内小方钮） */
.fx-toggle {
  border: 1px solid var(--border);
  background: var(--bg-elev2);
  color: var(--text-dim);
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: calc(12px * var(--scale-font));
  transition: all 0.12s;
  text-transform: none;
}
.fx-toggle:hover {
  border-color: var(--accent-bd);
  color: var(--accent);
}
/* 编号 #1 #2 — 方角、等宽、突出 */
.q-no {
  font-family: "JetBrains Mono", Consolas, monospace;
  background: var(--bg-elev2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  letter-spacing: 0;
  font-size: calc(14px * var(--scale-font));
}
/* 难度徽章 —— 醒目 实心底 + 白色文字 + hover 放大 */
.diff-badge {
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  letter-spacing: 0;
  font-size: calc(14px * var(--scale-font));
  text-transform: none;
  cursor: help; /* 暗示有 tooltip */
  transition:
    transform 0.12s ease,
    filter 0.12s ease;
  user-select: none;
}
.diff-badge:hover {
  transform: scale(1.08);
  filter: brightness(1.18);
}
/* 实心底 + 白字，书本风深饱和色 */
.diff-easy {
  background: var(--success);
  color: #fff;
  border-color: #186a3b;
}
.diff-medium {
  background: var(--warn);
  color: #fff;
  border-color: #8c5f13;
}
.diff-hard {
  background: var(--danger);
  color: #fff;
  border-color: #a93226;
}
.opts {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* 选项通用 */
.opt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    background 0.1s ease,
    border-color 0.1s ease;
}
.opt:hover {
  border-color: var(--border);
  background: var(--bg-elev2);
}
.opt.selected {
  border-color: var(--accent-bd);
  background: var(--accent-bg);
}
.opt.selected .opt-letter {
  color: var(--accent);
}
.opt input {
  margin-top: 3px;
  accent-color: var(--accent);
}
.opt-letter {
  font-weight: 600;
  color: var(--text-dim);
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: calc(15px * var(--scale-font));
  letter-spacing: 0.3px;
  min-width: 16px;
  transition: color 0.1s ease;
}
.opt-text {
  line-height: 1.6;
  white-space: pre-wrap;
  font-size: calc(16px * var(--scale-font));
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* 正确：低饱和绿，去掉 box-shadow */
.opt.correct {
  border-color: var(--success-bd);
  background: var(--success-bg);
}
.opt.correct .opt-letter {
  color: var(--success);
}

/* 错误：低饱和红，去掉 box-shadow + line-through */
.opt.wrong {
  border-color: var(--danger-bd);
  background: var(--danger-bg);
}
.opt.wrong .opt-letter {
  color: var(--danger);
  text-decoration: line-through;
  text-decoration-color: var(--danger);
  text-decoration-thickness: 1px;
}

/* 漏选：低饱和黄 */
.opt.missed {
  border-color: var(--warn-bd);
  background: var(--warn-bg);
}
.opt.missed .opt-letter {
  color: var(--warn);
}

.nav-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}
/* 历史浏览模式提示行 */
.review-hint {
  margin-top: 10px;
  font-size: calc(13px * var(--scale-font));
  color: var(--text-dim);
  text-align: center;
}
.nav-row .ai-btn {
  padding: 7px 10px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  color: #fff;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}
.nav-row .ai-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(102, 126, 234, 0.45);
}
.nav-row .ai-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ===== 操作题 ===== */
.op-body h4 {
  margin: 0 0 8px 0;
  color: var(--text-faint);
  font-size: calc(14px * var(--scale-font));
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
textarea,
#code-editor {
  width: 100%;
  min-height: 260px;
  background: var(--code-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: calc(16px * var(--scale-font));
  line-height: 1.65;
  resize: vertical;
  outline: none;
  transition: border-color 0.12s;
}
textarea:focus,
#code-editor:focus {
  border-color: var(--accent-bd);
}
.fill-input {
  min-height: 120px;
}
.run-output {
  background: var(--code-bg);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 10px;
  font-size: calc(15px * var(--scale-font));
  font-family: "JetBrains Mono", Consolas, monospace;
  white-space: pre-wrap;
  max-height: 300px;
  overflow: auto;
}
.explain {
  margin-top: 14px;
  background: var(--bg-elev2);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
}
.explain summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-dim);
  font-size: calc(15px * var(--scale-font));
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* ===== 结果 ===== */
.result-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
}
.result-card h2 {
  font-size: calc(40px * var(--scale-font));
  margin: 0 0 8px 0;
  color: var(--accent);
  letter-spacing: -0.5px;
}

/* ===== 题目中的图片 ===== */
.q-img {
  display: block;
  max-width: 100%;
  max-height: calc(420px * var(--scale-img));
  margin: 10px 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--bg-elev2);
  padding: 3px;
  cursor: zoom-in;
  transition: border-color 0.12s;
}
.q-img:hover {
  border-color: var(--border);
}
.q-img[src=""],
.q-img:not([src]) {
  display: none;
}

/* ===== 答题反馈条 ===== */
.feedback {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: calc(16px * var(--scale-font));
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid;
  flex-wrap: wrap; /* 手机窄屏：允许换行，防止中文被压成一字一行打竖 */
}
.feedback i {
  flex-shrink: 0;
}
.feedback.ok {
  background: var(--success-bg);
  border-color: var(--success-bd);
  color: var(--success);
}
.feedback.bad {
  background: var(--danger-bg);
  border-color: var(--danger-bd);
  color: var(--danger);
}
.feedback.early-hint {
  background: var(--warn-bg);
  border-color: var(--warn-bd);
  color: var(--warn);
}
.feedback strong {
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 1px;
}

/* ===== 数据缺失降级提示 ===== */
.q-data-warn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-top: 12px;
  background: rgba(192, 57, 43, 0.08);
  border: 1px solid rgba(192, 57, 43, 0.35);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: calc(16px * var(--scale-font));
}
.q-data-warn i {
  font-size: calc(18px * var(--scale-font));
}

/* ===== 知识点 tag ===== */
.knowledge-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: var(--radius-sm);
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid var(--accent-bd);
  font-weight: 600;
  font-size: calc(14px * var(--scale-font));
  letter-spacing: 0;
  text-transform: none;
}
.knowledge-tag i {
  font-size: calc(13px * var(--scale-font));
}

/* ===== 答错 ✕ 特效（全屏 overlay）===== */
.wrong-fx {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.08); /* 极淡暗化，衬托红色 */
  animation: wrong-fx-in 1.2s ease-out forwards;
}
.wrong-fx .wrong-mark {
  font-family: "Inter", "Segoe UI Variable", sans-serif;
  font-weight: 900;
  font-size: clamp(80px, 20vw, 220px);
  color: var(--danger);
  line-height: 1;
  text-shadow:
    0 0 20px rgba(192, 57, 43, 0.5),
    0 0 60px rgba(192, 57, 43, 0.3);
  animation: wrong-fx-bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes wrong-fx-in {
  0% {
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  85% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}
@keyframes wrong-fx-bounce {
  0% {
    transform: scale(0.3) rotate(-12deg);
    opacity: 0;
  }
  40% {
    transform: scale(1.2) rotate(4deg);
    opacity: 1;
  }
  60% {
    transform: scale(0.95) rotate(-2deg);
  }
  80% {
    transform: scale(1.05) rotate(1deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}

/* ===== 答对 ✓ 特效（简化版）===== */
.right-fx {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  animation: right-fx-in 1s ease-out forwards;
}
.right-fx .right-mark {
  font-family: "Inter", "Segoe UI Variable", sans-serif;
  font-weight: 900;
  font-size: clamp(60px, 14vw, 160px);
  color: var(--success);
  animation: right-fx-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes right-fx-in {
  0% {
    opacity: 0;
  }
  30% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}
@keyframes right-fx-pop {
  0% {
    transform: scale(0.2);
    opacity: 0;
  }
  50% {
    transform: scale(1.15);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ===== 选项区 shake 错配时 ===== */
@keyframes shake-opt {
  0%,
  100% {
    transform: translateX(0);
  }
  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-6px);
  }
  20%,
  40%,
  60%,
  80% {
    transform: translateX(6px);
  }
}
.opt.shake {
  animation: shake-opt 0.45s ease 2;
}

/* ===== 选项选中 pulse 动画 ===== */
@keyframes opt-pulse {
  0% {
    box-shadow: 0 0 0 0 var(--accent);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(44, 82, 130, 0.28);
    transform: scale(1.015);
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
    transform: scale(1);
  }
}
.opt.opt-pulse {
  animation: opt-pulse 0.3s ease-out;
}

/* ===== 选项角标 ===== */
.opt {
  position: relative;
}
.opt-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
  animation: badge-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.badge-correct {
  background: var(--success);
  color: #fff;
  box-shadow: 0 2px 6px rgba(30, 126, 70, 0.4);
}
.badge-wrong {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 2px 6px rgba(192, 57, 43, 0.4);
}
.badge-missed {
  background: var(--warn);
  color: #fff;
  box-shadow: 0 2px 6px rgba(181, 122, 26, 0.4);
}
@keyframes badge-pop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  70% {
    transform: scale(1.2);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

/* ===== SM-2 状态徽章（反馈条里） ===== */
.sm2-badge {
  margin-left: auto;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: calc(13px * var(--scale-font));
  font-weight: 600;
  white-space: nowrap;
  animation: sm2-slide-in 0.35s ease-out both;
}
.sm2-badge.up {
  background: var(--success-bg);
  border: 1px solid var(--success-bd);
  color: var(--success);
}
.sm2-badge.down {
  background: var(--danger-bg);
  border: 1px solid var(--danger-bd);
  color: var(--danger);
}
@keyframes sm2-slide-in {
  0% {
    opacity: 0;
    transform: translateX(8px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ===== 切题过渡：fade + slide up ===== */
.question-card {
  animation: card-in 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes card-in {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== 选项锁定（最后5秒 / 已提交） ===== */
.opt.locked {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}
.opt.locked input {
  cursor: not-allowed;
}

/* ===== 按钮 success / danger 态 ===== */
.btn.success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn.success:hover {
  background: #156e3e;
  border-color: #156e3e;
}
.btn.danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn.danger:hover {
  background: #a32e23;
  border-color: #a32e23;
}

/* ===== 图片查看器（fixed overlay — 手机/桌面通用） ===== */
.q-img-viewer {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: viewerFade 0.18s ease-out;
}
@keyframes viewerFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.q-img-viewer .viewer-img-wrap {
  max-width: 96vw;
  max-height: 92vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.q-img-viewer img {
  max-width: 100%;
  max-height: 88vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.q-img-viewer .close-btn {
  position: fixed;
  top: env(safe-area-inset-top, 14px);
  right: 14px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.12s,
    transform 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.q-img-viewer .close-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}
.q-img-viewer .close-btn:active {
  transform: scale(0.92);
}
.q-img-viewer .viewer-hint {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 14px) + 6px);
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  pointer-events: none;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
}

/* 手机优化：更大的关闭按钮 + 避免双指缩放干扰 */
@media (max-width: 600px) {
  .q-img-viewer .close-btn {
    width: 50px;
    height: 50px;
    font-size: 22px;
    top: 10px;
    right: 10px;
  }
  .q-img-viewer img {
    max-height: 82vh;
  }
  .q-img-viewer .viewer-hint {
    display: none;
  }
}

/* ===== 笔记面板 ===== */
.notes-panel {
  margin-top: 16px;
}
.notes-panel > summary {
  font-weight: 600;
  font-size: calc(14px * var(--scale-font));
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(44, 82, 130, 0.06), rgba(44, 82, 130, 0.02));
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  transition: background 0.15s;
}
.notes-panel > summary::-webkit-details-marker {
  display: none;
}
.notes-panel > summary::before {
  content: "▶";
  font-size: 10px;
  transition: transform 0.15s;
  color: var(--text-dim);
}
.notes-panel[open] > summary::before {
  transform: rotate(90deg);
}
.notes-panel > summary:hover {
  background: linear-gradient(135deg, rgba(44, 82, 130, 0.1), rgba(44, 82, 130, 0.04));
}
.notes-panel > summary .notes-badge {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  gap: 8px;
  font-weight: 400;
}
.notes-body {
  padding: 14px 4px 4px 4px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.thoughts-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card, #f2ede1);
  color: var(--text);
  font-size: calc(14px * var(--scale-font));
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  box-sizing: border-box;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.thoughts-textarea:focus {
  outline: none;
  border-color: var(--accent, #2c5282);
  box-shadow: 0 0 0 3px rgba(44, 82, 130, 0.12);
}
.thoughts-textarea::placeholder {
  color: var(--text-faint, #a0988a);
}
.images-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
}
.note-img-wrap {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  transition:
    transform 0.12s,
    box-shadow 0.12s;
}
.note-img-wrap:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.note-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.note-img-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  opacity: 0;
  transition:
    opacity 0.15s,
    background 0.12s;
}
.note-img-wrap:hover .note-img-del {
  opacity: 1;
}
.note-img-del:hover {
  background: rgba(248, 81, 73, 0.9);
}
.note-img-upload {
  width: 100px;
  height: 100px;
  border-radius: 8px;
  border: 2px dashed var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 12px;
  transition:
    border-color 0.15s,
    color 0.15s,
    background 0.15s;
  background: transparent;
}
.note-img-upload:hover {
  border-color: var(--accent, #2c5282);
  color: var(--accent, #2c5282);
  background: rgba(44, 82, 130, 0.04);
}
.note-img-upload.loading {
  pointer-events: none;
  opacity: 0.6;
}
.note-img-upload i {
  font-size: 20px;
}
.notes-empty {
  font-size: 12px;
  color: var(--text-faint, #a0988a);
  text-align: center;
  padding: 10px;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 6px;
  border: 1px dashed var(--border);
}
.notes-empty i {
  margin-right: 4px;
  color: var(--accent, #2c5282);
  opacity: 0.6;
}

/* ===== C Playground 引导区 ===== */
.c-playground {
  margin-bottom: 20px;
}
/* C 引导区 Tab：自由练习 / 题目抄写 */
.cp-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
}
.cp-tabs h3 {
  margin: 0;
  font-size: calc(15px * var(--scale-font));
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.4px;
}
.cp-tab-btns {
  display: flex;
  gap: 2px;
  background: var(--bg-elev2, #eae4d6);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.cp-tab {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 5px 14px;
  border-radius: calc(var(--radius-sm) - 1px);
  font-size: calc(13px * var(--scale-font));
  color: var(--text-dim, #6b6050);
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.cp-tab:hover {
  color: var(--text);
}
.cp-tab.active {
  background: var(--card-bg, #fff);
  color: var(--accent, #2c5282);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(60, 45, 20, 0.14);
}
.cp-head .cp-sub {
  margin-left: 0;
}

.cp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.cp-head h3 {
  margin: 0;
  font-size: calc(15px * var(--scale-font));
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.4px;
}
.cp-sub {
  font-size: calc(12px * var(--scale-font));
  color: var(--text-faint);
  font-weight: 400;
  margin-left: 8px;
  letter-spacing: 0;
}
.cp-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.cp-select {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text);
  font-size: calc(14px * var(--scale-font));
  cursor: pointer;
  font-family: inherit;
}
.cp-select:hover {
  border-color: var(--accent-bd);
}
.cp-run {
  min-width: 100px;
}
.cp-ai {
  gap: 5px;
}
.cp-ai:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.cp-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.cp-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--code-bg);
}
.cp-editor .cm-editor {
  height: 100%;
}
.cp-output-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #1e1e2e;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cp-output-title {
  padding: 8px 12px;
  font-size: calc(12px * var(--scale-font));
  color: #a6adc8;
  background: #181825;
  border-bottom: 1px solid #313244;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "JetBrains Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cp-badge-warn {
  color: #f38ba8;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}
.cp-badge-idle {
  color: #6c7086;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: calc(11px * var(--scale-font));
}
.cp-output {
  flex: 1;
  padding: 12px;
  overflow: auto;
  min-height: 150px;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: calc(14px * var(--scale-font));
  line-height: 1.65;
  color: #a6e3a1;
  white-space: pre-wrap;
  word-break: break-all;
}
.cp-output.cp-error {
  color: #f38ba8;
}
.cp-output.cp-empty,
.cp-output:empty::before {
  content: "等待运行…";
  color: #6c7086;
  font-style: italic;
}

/* ===== 内置错误解读卡片 ===== */
.cp-explain {
  border-top: 1px solid #313244;
  background: #11111b;
  padding: 10px 12px;
}
.cp-explain-title {
  color: #a6adc8;
  font-size: calc(12px * var(--scale-font));
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-weight: 500;
}
.cp-rt-error {
  background: rgba(243, 139, 168, 0.15);
  border-left: 3px solid #f38ba8;
  padding: 8px 12px;
  color: #f38ba8;
  font-size: calc(13px * var(--scale-font));
  margin-bottom: 8px;
}
.cp-issue {
  background: #1e1e2e;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  border-left: 3px solid #89dceb;
}
.cp-issue.error {
  border-left-color: #f38ba8;
}
.cp-issue.warning {
  border-left-color: #fab387;
}
.cp-issue-head {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px;
  font-size: calc(12px * var(--scale-font));
}
.cp-issue-badge {
  font-weight: 600;
}
.cp-issue.error .cp-issue-badge {
  color: #f38ba8;
}
.cp-issue.warning .cp-issue-badge {
  color: #fab387;
}
.cp-issue-line {
  color: #cba6f7;
  font-family: "JetBrains Mono", monospace;
}
.cp-issue-type {
  color: #89b4fa;
}
.cp-issue-raw {
  color: #cdd6f4;
  font-family: "JetBrains Mono", monospace;
  font-size: calc(12px * var(--scale-font));
  margin-bottom: 6px;
  word-break: break-all;
  white-space: pre-wrap;
}
.cp-issue-explain {
  color: #a6e3a1;
  font-size: calc(13px * var(--scale-font));
  margin-bottom: 4px;
}
.cp-issue-suggest {
  color: #f9e2af;
  font-size: calc(13px * var(--scale-font));
}

/* ===== DeepSeek webview 面板 ===== */
.cp-deepseek {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  overflow: hidden;
  position: relative;
}
.cp-deepseek-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  gap: 8px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #1a1a3e 0%, #2d1b69 100%);
  color: #e0e0e0;
}
.cp-deepseek-title {
  font-size: calc(14px * var(--scale-font));
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
}
.cp-deepseek-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.cp-deepseek-body {
  min-height: 480px;
  display: flex;
}
.cp-webview {
  width: 100%;
  min-height: 480px;
  display: block;
  border: none;
  background: #fff;
}
.cp-webview-fallback {
  flex: 1;
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 20px;
  color: var(--text-faint);
}
.cp-webview-fallback i {
  font-size: 48px;
  opacity: 0.3;
}

/* C Playground — 响应式 */
@media (max-width: 900px) {
  .cp-body {
    grid-template-columns: 1fr;
  }
  .cp-output {
    min-height: 120px;
    max-height: 220px;
  }
}
@media (max-width: 600px) {
  .cp-head {
    flex-direction: column;
    align-items: stretch;
  }
  .cp-sub {
    display: none;
  }
  .cp-actions {
    justify-content: stretch;
  }
  .cp-select {
    flex: 1;
    min-width: 0;
  }
  .cp-deepseek-head {
    flex-direction: column;
    align-items: stretch;
  }
  .cp-deepseek-title {
    margin-bottom: 6px;
  }
}

/* ===== 响应式 — 4 档断点覆盖所有关键布局 ===== */

/* 桌面小屏 / 平板横屏（≤1200px）— hero 4 列变 3 列 */
@media (max-width: 1200px) {
  #app {
    max-width: 1000px;
  }
}

/* 平板（≤900px）— hero 3 列变 2 列，grid-2 变单列 */
@media (max-width: 900px) {
  .hero {
    grid-template-columns: repeat(2, 1fr);
  }
  .hero > :last-child:nth-child(2n + 1) {
    grid-column: span 2;
  }
  .hero > :last-child:nth-child(2n + 2) {
    grid-column: span 2;
  }
  .stat-card.big {
    grid-column: span 2;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
  #app {
    padding: 16px;
  }
  .chapter-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
  .question-card {
    padding: 16px;
  }
  .nav-row {
    flex-wrap: wrap;
  }
  .nav-row .btn {
    flex: 1;
    min-width: 120px;
    text-align: center;
  }
}

/* 手机横屏 / 大手机（≤600px）— hero 2 列，顶栏压缩 */
@media (max-width: 600px) {
  #app {
    padding: 12px;
  }
  /* Hero：2 列小卡布局（用户说的 4-6 布局 — 即 6 张小卡分 2 列，每列 3 张）*/
  .hero {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .stat-card.big {
    grid-column: span 2;
  }
  .hero > :last-child {
    grid-column: span 1;
  }
  /* App 名称独立行（hero 之前） */
  .app-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 0 14px;
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.5px;
  }
  .app-title-row i {
    margin-right: 8px;
    font-size: 20px;
  }
  .stat-card {
    padding: 10px 12px;
  }
  .stat-num {
    font-size: calc(22px * var(--scale-font));
  }
  .stat-label {
    font-size: calc(11px * var(--scale-font));
    letter-spacing: 0.6px;
  }
  .topbar {
    padding: 10px 12px;
    gap: 6px;
  }
  .topbar .zoom-group {
    order: 3;
    margin-left: auto;
  }
  .topbar select {
    font-size: 13px;
    max-width: 100px;
  }
  .question-card {
    padding: 14px;
  }
  .q-title {
    font-size: calc(17px * var(--scale-font));
  }
  .opts {
    gap: 4px;
  }
  .opt {
    padding: 8px 10px;
  }
  .opt-text {
    font-size: calc(15px * var(--scale-font));
  }
  .practice-wrap {
    padding: 0 4px;
  }
  .chapter-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
  /* 表格：小屏让题目列可收缩 */
  .table .q-title {
    max-width: 180px;
  }
  .table th,
  .table td {
    padding: 6px 6px;
    font-size: calc(14px * var(--scale-font));
  }
  .history-header {
    flex-wrap: wrap;
  }
  /* 手机：题干术语允许换行（nowrap 在极窄屏会横向撑出容器） */
  .q-term {
    white-space: normal;
  }
  /* 手机：反馈条/数据提示文字换行而不是压缩 */
  .q-data-warn {
    flex-wrap: wrap;
  }
  .result-card h2 {
    font-size: calc(28px * var(--scale-font));
  }
  .feedback {
    font-size: calc(14px * var(--scale-font));
  }
  /* 手机：进度条徽章与计数保持同行不重叠 */
  .progress-bar .streak-badge {
    max-width: 45%;
    overflow: hidden;
  }
  .progress-bar .accuracy-badge {
    font-size: calc(11px * var(--scale-font));
    padding: 2px 7px;
    left: auto;
    right: 0;
    transform: none;
  }
}

/* 小屏手机（≤420px）— 极限压缩 */
@media (max-width: 420px) {
  .topbar {
    padding: 8px 10px;
  }
  .topbar .clock {
    display: none;
  }
  .topbar select {
    max-width: 90px;
  }
  .zoom-group .zoom-label:not(:first-child) {
    display: none;
  }
  .zoom-reset {
    display: none;
  }
  .question-card {
    padding: 12px;
    border-radius: var(--radius);
  }
  .q-meta {
    font-size: calc(12px * var(--scale-font));
    gap: 6px;
  }
  .q-no {
    font-size: calc(12px * var(--scale-font));
    padding: 0 5px;
  }
  .opt-letter {
    font-size: calc(14px * var(--scale-font));
    min-width: 14px;
  }
  .nav-row {
    gap: 6px;
  }
  .nav-row .btn {
    font-size: calc(14px * var(--scale-font));
    padding: 6px 10px;
  }
  .result-card {
    padding: 24px 16px;
  }
}

/* =====================================================
 * 📱 移动端重构（Capacitor Android）— 追加层
 * 包含：safe-area 适配 / BottomTabBar / 48dp 触摸目标 / :active 反馈 / Material 3 形态
 * ===================================================== */

/* --- 1. 全局 safe-area 适配（JS 已注入 --sa-top/right/bottom/left）--- */
:root {
  --sa-top: 0px;
  --sa-right: 0px;
  --sa-bottom: 0px;
  --sa-left: 0px;
}
/* 安全区域在 viewport-fit=cover 浏览器里也能用 */
@supports (padding-top: env(safe-area-inset-top)) {
  :root {
    --sa-top: max(0px, env(safe-area-inset-top));
    --sa-right: max(0px, env(safe-area-inset-right));
    --sa-bottom: max(0px, env(safe-area-inset-bottom));
    --sa-left: max(0px, env(safe-area-inset-left));
  }
}

.mobile-shell .topbar {
  padding-top: calc(12px + var(--sa-top));
  padding-bottom: 8px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.mobile-shell .topbar .clock {
  display: none;
}
.mobile-shell .topbar .zoom-group {
  display: none;
}
.mobile-shell .topbar .brand {
  font-size: 16px;
}

/* --- 2. BottomTabBar --- */
.bottom-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  height: calc(58px + var(--sa-bottom));
  padding-bottom: var(--sa-bottom);
  background: var(--bg);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
  -webkit-tap-highlight-color: transparent;
}
.btb-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  color: var(--text-dim);
  font-size: 11px;
  text-decoration: none;
  position: relative;
  cursor: pointer;
  transition:
    color 0.15s ease,
    background 0.15s ease;
}
.btb-item .btb-icon {
  font-size: 22px;
  line-height: 1;
  padding: 4px;
  border-radius: 12px;
  transition: background 0.2s ease;
}
.btb-item.active {
  color: var(--accent);
  font-weight: 600;
}
.btb-item.active .btb-icon {
  background: var(--accent-bg);
}
.btb-item:active {
  background: var(--bg-hover);
}
/* 首页到期数量徽章 */
.btb-badge {
  position: absolute;
  top: 2px;
  right: calc(50% - 22px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--bg);
}

/* --- 3. 内容区底部留白（给 BottomTabBar 让位置）--- */
.app-main.with-bottom-bar {
  padding-bottom: calc(72px + var(--sa-bottom));
}

/* 普通非 topbar 页面（Practice/Syllabus）也给底部 tab bar 让位置 */
body > .bottom-tabbar {
  display: none;
}
.mobile-shell > .bottom-tabbar {
  display: flex;
}

/* ============ 桌面端左侧 Sidebar（书本风浅色主题）============ */
.desktop-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}
.desktop-shell > .app-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.desktop-shell > .app-body > .app-main {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 0;
}

/* --- 侧边栏本体 — 象牙米白系（与主界面统一书本风）--- */
.course-sidebar {
  width: 232px;
  flex-shrink: 0;
  height: 100vh;
  background: var(--bg-elev); /* 卡片档米白，比主背景深一档 */
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  color: var(--text);
  font-size: 13px;
  overflow: hidden;
  user-select: none;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.brand-logo {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--accent); /* 书脊靛蓝 */
  border-radius: var(--radius);
  font-size: 15px;
  color: #fff;
  flex-shrink: 0;
}
.brand-name {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
  color: var(--text);
}
.brand-sub {
  font-size: 11px;
  color: var(--text-faint);
}

.sidebar-badge {
  margin: 8px 12px 6px;
  padding: 5px 10px;
  font-size: 11px;
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--warn-bd);
  border-radius: var(--radius-sm);
  text-align: center;
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 4px;
}
.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.nav-group {
  margin-bottom: 10px;
}
.nav-group-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 10px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}
.nav-group-count {
  margin-left: auto;
  font-size: 10px;
  background: var(--bg-elev2);
  padding: 1px 7px;
  border-radius: 10px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  margin: 1px 0;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  transition:
    background 0.12s,
    color 0.12s;
  font-family: inherit;
}
.nav-item:hover:not(.disabled) {
  background: var(--bg-hover);
  color: var(--accent);
}
.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
  border-left: 3px solid var(--accent); /* 书脊靛蓝竖条 */
  padding-left: 7px; /* 抵消边框 3px */
}
.nav-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  font-style: italic;
  color: var(--text-faint);
}
.nav-item.locked {
  opacity: 0.7;
  color: var(--text-dim);
}
.nav-item-meta {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-faint);
}
.nav-item.active .nav-item-meta {
  color: var(--accent);
}
.nav-item.subtle {
  font-size: 12px;
  color: var(--text-dim);
  padding: 6px 10px;
}
.nav-item.subtle:hover {
  color: var(--accent);
}

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* --- 桌面 TopBar 精简 --- */
.desktop-shell .topbar {
  padding: 6px 16px;
  min-height: 44px;
}
.desktop-shell .topbar .brand {
  display: none;
}
.desktop-shell .topbar .course-switch {
  display: none;
}

/* --- 4. 触摸反馈：把 :hover 换成 :active（移动端），桌面保留 :hover --- */
/* 移动端（max-width: 900px）— 关闭所有 :hover 样式，加 :active 反馈 */

/* 工具类：手机端显示 / 隐藏 */
.mobile-only {
  display: none;
}
.mobile-hidden {
  display: block;
}
@media (max-width: 600px) {
  .mobile-only {
    display: flex;
  }
  .mobile-hidden {
    display: none;
  }
}
@media (max-width: 900px) {
  .btn:hover:not(:disabled),
  .topbar .zoom-group button:hover:not(:disabled),
  .chapter-card:hover,
  .due-row:hover,
  .tab-btn:hover,
  .mini-btn:hover,
  .opt:hover,
  .q-img:hover,
  .nav-row .ai-btn:hover:not(:disabled),
  .notes-panel > summary:hover,
  .note-img-wrap:hover {
    background: transparent;
    border-color: inherit;
    color: inherit;
    transform: none;
    box-shadow: none;
  }
  /* :active — 真实的触摸反馈 */
  .btn:active:not(:disabled),
  .chapter-card:active,
  .due-row:active,
  .tab-btn:active,
  .mini-btn:active,
  .opt:active,
  .nav-row .ai-btn:active:not(:disabled),
  .topbar select:focus {
    background: var(--bg-hover);
    border-color: var(--accent-bd);
    transform: scale(0.98);
    transition:
      transform 0.08s ease,
      background 0.08s ease;
  }
  /* Material 3 风格：按钮点击涟漪 */
  .btn.primary:active:not(:disabled) {
    background: var(--accent-dim);
  }
  .btb-item:active {
    transform: none; /* bottom tab 已经有 :active bg，不需要缩放 */
  }
}

/* --- 5. 触摸目标 ≥ 48dp（Google Material Design HIG 标准）--- */
@media (max-width: 900px) {
  .btn,
  .mini-btn,
  .tab-btn,
  .opt,
  .chapter-card,
  .topbar .btn,
  .btb-item {
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .topbar .btn,
  .settings-btn,
  .zoom-reset,
  .icon-btn {
    min-width: 44px;
    min-height: 44px;
  }
}

/* --- 6. 选项 Material 3 形态（移动端）--- */
@media (max-width: 900px) {
  .opt {
    border-radius: 16px;
    padding: 12px 14px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  }
  .opt.selected {
    box-shadow: 0 2px 8px var(--accent-bg);
  }
}

/* --- 7. 禁用长按弹出菜单（安卓 WebView 体验问题）--- */
* {
  -webkit-user-select: text;
  user-select: text;
}
button,
.btb-item,
.opt,
.chapter-card {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* --- 8. 桌面（>900px）的 hover 增强 — 保持原样不被移动端块干扰 --- */
@media (min-width: 901px) {
  .chapter-card:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  }
  .opt:hover {
    border-color: var(--border);
    background: var(--bg-elev2);
  }
  .btn:hover:not(:disabled) {
    background: var(--bg-hover);
  }
}
