/* ============================================================
   学习刷题 · 现代设计样式表
   设计语言：Soft Modern —— 柔和渐变 + 分层阴影 + 玻璃质感
   全站基于 CSS 变量，支持浅色 / 深色双主题（body.dark）
   ============================================================ */

/* ===== 设计 Token ===== */
:root {
  /* 品牌色（墨墨风 · 薄荷青 / teal） */
  --primary: #14b8a6;          /* teal-500 */
  --primary-2: #06b6d4;        /* cyan-500 */
  --primary-dark: #0d9488;     /* teal-600 */
  --primary-soft: #ccfbf1;     /* teal-50 */
  --on-primary: #ffffff;

  /* 中性面 */
  --bg: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;        /* slate-50 */
  --surface-3: #f1f5f9;
  --border: #e8eaf1;
  --border-strong: #d6dae6;

  /* 文字 */
  --text: #0f172a;             /* slate-900 */
  --text-2: #475569;           /* slate-600 */
  --muted: #94a3b8;            /* slate-400 */

  /* 语义色 */
  --green: #10b981;  --green-soft: #d1fae5;  --green-ink: #065f46;
  --red: #ef4444;    --red-soft: #fee2e2;    --red-ink: #991b1b;
  --amber: #f59e0b;  --amber-soft: #fef3c7;  --amber-ink: #92400e;
  --blue: #3b82f6;   --blue-soft: #dbeafe;   --blue-ink: #1e40af;
  --violet: #8b5cf6; --violet-soft: #ede9fe; --violet-ink: #6d28d9;
  --indigo: #6366f1; --indigo-soft: #e0e7ff; --indigo-ink: #3730a3;

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

  /* 阴影（分层柔和） */
  --shadow-sm: 0 1px 2px rgba(15,23,42,.05), 0 1px 3px rgba(15,23,42,.04);
  --shadow: 0 2px 6px rgba(15,23,42,.05), 0 10px 24px rgba(15,23,42,.05);
  --shadow-lg: 0 10px 30px rgba(15,23,42,.10), 0 18px 50px rgba(15,23,42,.08);
  --shadow-primary: 0 8px 22px rgba(20,184,166,.34);
  --shadow-danger: 0 8px 22px rgba(239,68,68,.30);

  /* 渐变 */
  --grad-primary: linear-gradient(135deg, #14b8a6 0%, #06b6d4 100%);
  --grad-danger: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
  --grad-success: linear-gradient(135deg, #34d399 0%, #10b981 100%);

  /* 焦点环 */
  --ring: 0 0 0 3px rgba(20,184,166,.28);

  /* 字体 */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;

  /* 安全区 */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* 兼容旧名 */
  --card: var(--surface);
}

/* ===== 深色主题 ===== */
body.dark {
  --primary: #2dd4bf;
  --primary-2: #22d3ee;
  --primary-dark: #14b8a6;
  --primary-soft: #042f2e;
  --on-primary: #ffffff;

  --bg: #080d1a;
  --surface: #131a2e;
  --surface-2: #18203a;
  --surface-3: #1f2942;
  --border: #25304a;
  --border-strong: #33405e;

  --text: #e9eef9;
  --text-2: #aab4ca;
  --muted: #6b7895;

  --green: #34d399;  --green-soft: #0b2e22;  --green-ink: #6ee7b7;
  --red: #f87171;    --red-soft: #3a1414;    --red-ink: #fca5a5;
  --amber: #fbbf24;  --amber-soft: #3a2a08;   --amber-ink: #fcd34d;
  --blue: #60a5fa;   --blue-soft: #122245;    --blue-ink: #93c5fd;
  --violet: #a78bfa; --violet-soft: #241a4d;  --violet-ink: #c4b5fd;
  --indigo: #818cf8; --indigo-soft: #1e1b4b;  --indigo-ink: #a5b4fc;

  --shadow: 0 2px 8px rgba(0,0,0,.45), 0 12px 36px rgba(0,0,0,.40);
  --shadow-lg: 0 14px 44px rgba(0,0,0,.55), 0 24px 70px rgba(0,0,0,.45);
  --shadow-primary: 0 8px 22px rgba(45,212,191,.42);
  --shadow-danger: 0 8px 22px rgba(248,113,113,.38);

  --grad-primary: linear-gradient(135deg, #14b8a6 0%, #06b6d4 100%);
  --grad-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  --grad-success: linear-gradient(135deg, #10b981 0%, #059669 100%);

  --ring: 0 0 0 3px rgba(45,212,191,.40);
  --card: var(--surface);
}

/* ===== 基础 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  background-image: radial-gradient(1100px 560px at 50% -12%, rgba(20,184,166,.10), transparent 62%);
  background-attachment: fixed;
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .3s ease, color .3s ease;
}
body.dark {
  background-image: radial-gradient(1100px 560px at 50% -12%, rgba(20,184,166,.16), transparent 62%);
}

button {
  font: inherit; color: inherit; background: none; border: none;
  cursor: pointer; touch-action: manipulation;
}

input, textarea, select {
  font: inherit; color: var(--text);
  font-size: 16px; /* ≥16px 避免 iOS Safari 聚焦输入框时整页自动放大 */
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  background: var(--surface);
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--primary); box-shadow: var(--ring);
}

/* 自定义滚动条 */
main::-webkit-scrollbar, .preview-box::-webkit-scrollbar, .modal::-webkit-scrollbar { width: 7px; }
main::-webkit-scrollbar-thumb, .preview-box::-webkit-scrollbar-thumb, .modal::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: var(--radius-pill);
}

/* ===== 顶栏 ===== */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(11px + var(--safe-top)) 16px 11px;
  background: var(--grad-primary);
  color: var(--on-primary);
  box-shadow: 0 6px 20px rgba(13,148,136,.30);
}
.topbar h1 {
  display: flex; align-items: center; gap: 9px;
  font-size: 18px; font-weight: 800; letter-spacing: .3px;
}
.brand-dot {
  width: 13px; height: 13px; border-radius: 5px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 0 0 3px rgba(255,255,255,.25);
}
.top-actions { display: flex; gap: 8px; }
.top-actions button {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,.20);
  color: #fff; border: 1px solid rgba(255,255,255,.22);
  border-radius: 10px; padding: 7px 12px; font-size: 13px; font-weight: 600;
  backdrop-filter: blur(6px);
  transition: background .15s ease, transform .08s ease;
}
.top-actions button:active { background: rgba(255,255,255,.34); transform: scale(.96); }

/* ===== 主题切换图标（与底部栏同款：1024 画布、实心填充、currentColor 跟随主题） ===== */
#btn-theme { padding: 6px 9px; line-height: 1; }
#btn-theme svg {
  width: 19px; height: 19px; display: block;
  fill: currentColor;                       /* 顶栏为渐变底 + 白色字，图标自动为白 */
}
/* 浅色态显示「月亮」（点击转深色），深色态显示「太阳」（点击转浅色） */
#btn-theme .ico-moon { display: block; }
#btn-theme .ico-sun  { display: none; }
body.dark #btn-theme .ico-moon { display: none; }
body.dark #btn-theme .ico-sun  { display: block; animation: themePop .38s cubic-bezier(.34,1.4,.52,1); }
@keyframes themePop {
  from { opacity: 0; transform: rotate(-70deg) scale(.55); }
  to   { opacity: 1; transform: rotate(0) scale(1); }
}

/* ===== 主区 ===== */
main {
  position: fixed; inset: 0;
  padding: calc(58px + var(--safe-top)) 12px calc(66px + var(--safe-bottom));
  overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
}
.view { display: none; }
.view.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 切换 Tab：按方向滑动入场（右→左 / 左→右），位移仅 16px，避免撑出横向滚动 */
.view.active.slide-r { animation: viewInR .24s cubic-bezier(.22,.61,.36,1); }
.view.active.slide-l { animation: viewInL .24s cubic-bezier(.22,.61,.36,1); }
@keyframes viewInR { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
@keyframes viewInL { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: translateX(0); } }
@media (prefers-reduced-motion: reduce) {
  .view.active, .view.active.slide-r, .view.active.slide-l,
  .tabbar button.active::after,
  .tabbar button.sq-pop,
  #btn-theme .ico-sun { animation: none; }
  .tabbar button, .tabbar button .ico, .tabbar button .lbl,
  .tabbar button::after { transition: none; }
}

/* ===== 底部导航（玻璃质感 + 活跃指示） ===== */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex;
  /* 实心不透明：避免刷题等内容透过底栏显示 */
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 14px rgba(15,23,42,.06);
  padding-bottom: var(--safe-bottom);
}
.tabbar button {
  position: relative;
  flex: 1;                         /* 等宽：按钮宽度全程不变，只有内部文字收放 */
  display: flex; align-items: center; justify-content: center;
  padding: 13px 0;
  font-size: 13px; color: var(--muted);
  transition: color .45s ease;
}
/* 实心填充风格图标 */
.tabbar button .ico {
  width: 22px; height: 22px; flex: 0 0 auto; line-height: 1; color: var(--muted);
  transition: color .45s ease;
}
.tabbar button .ico svg { width: 100%; height: 100%; fill: currentColor; }
/* 标签文字：未激活时宽度收为 0，激活时从图标右侧横向"抽"出来 */
.tabbar button .lbl {
  display: inline-block; white-space: nowrap; overflow: hidden; line-height: 1.2;
  max-width: 0; margin-left: 0; opacity: 0;
  transition: max-width .72s cubic-bezier(.16,.84,.44,1),
              margin-left .72s cubic-bezier(.16,.84,.44,1),
              opacity .45s ease;
}
.tabbar button.active { color: var(--primary); font-weight: 700; }
.tabbar button.active .ico { color: var(--primary); }
.tabbar button.active .lbl { max-width: 100px; margin-left: 6px; opacity: 1; }
/* 底部指示条：从中心横向展开 */
.tabbar button::after {
  content: ""; position: absolute; bottom: 0; left: 30%; right: 30%; height: 3px;
  border-radius: 3px 3px 0 0; background: var(--primary);
  transform: scaleX(0); opacity: 0; transform-origin: center;
  transition: transform .72s cubic-bezier(.16,.84,.44,1), opacity .5s ease;
}
.tabbar button.active::after { transform: scaleX(1); opacity: 1; }

/* ===== 通用组件 ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
  transition: transform .16s ease, box-shadow .2s ease;
}
@media (hover: hover) { .card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); } }
.card h3 { font-size: 15px; margin-bottom: 8px; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-weight: 700; font-size: 15px; letter-spacing: .2px;
  background: var(--grad-primary); color: #fff;
  box-shadow: var(--shadow-primary);
  width: 100%;
  transition: transform .08s ease, box-shadow .2s ease, filter .2s ease;
}
.btn:active { transform: scale(.975); filter: brightness(.96); }
.btn.ghost { background: var(--primary-soft); color: var(--primary); box-shadow: none; }
.btn.danger { background: var(--grad-danger); color: #fff; box-shadow: var(--shadow-danger); }
.btn.sm { min-height: 38px; padding: 7px 13px; font-size: 13px; border-radius: 10px; width: auto; }
.btn:disabled { opacity: .5; pointer-events: none; filter: grayscale(.3); }

.badge {
  display: inline-block; padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 700; line-height: 1.5;
  background: var(--primary-soft); color: var(--primary-dark);
}
.badge.single { background: var(--blue-soft); color: var(--blue-ink); }
.badge.multi  { background: var(--violet-soft); color: var(--violet-ink); }
.badge.fill   { background: var(--amber-soft); color: var(--amber-ink); }
.badge.judge  { background: var(--indigo-soft); color: var(--indigo-ink); }
.badge.card   { background: var(--green-soft); color: var(--green-ink); }

.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.empty .big { font-size: 46px; margin-bottom: 12px; filter: saturate(.9); }
.empty .big { opacity: .85; }

/* ===== 题库视图 ===== */
.chapter-head {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 8px; cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.chapter-head:active { background: var(--surface-2); }
.chapter-head .arrow { transition: transform .18s ease; color: var(--muted); }
.chapter-head.open .arrow { transform: rotate(90deg); color: var(--primary); }
.chapter-head .count { color: var(--muted); font-size: 12px; }

.qitem {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 13px 14px;
  margin: 0 0 8px;
  display: flex; align-items: flex-start; gap: 8px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.qitem:active { border-color: var(--border-strong); }
.qitem .text { flex: 1; min-width: 0; }
.qitem .stem {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; font-size: 14px; color: var(--text);
}
.qitem .del { color: var(--muted); padding: 4px 6px; font-size: 16px; border-radius: 8px; }
.qitem .del:active { color: var(--red); background: var(--red-soft); }

/* ===== 刷题视图 ===== */
.quiz-setup label {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 4px; min-height: 46px;
  font-weight: 500;
}
.quiz-setup input[type="checkbox"], .quiz-setup input[type="radio"] {
  width: 20px; height: 20px; accent-color: var(--primary); flex: none;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.chip {
  padding: 9px 15px; border-radius: var(--radius-pill);
  border: 1.5px solid var(--border); background: var(--surface);
  font-size: 13px; color: var(--muted); font-weight: 500;
  transition: all .15s ease;
}
.chip.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 700; }

.progress { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; color: var(--muted); font-size: 13px; }
.progress .bar { flex: 1; height: 7px; background: var(--border); border-radius: var(--radius-pill); overflow: hidden; }
.progress .bar i { display: block; height: 100%; background: var(--grad-primary); border-radius: var(--radius-pill); transition: width .25s ease; }

.qstem { font-size: 16px; font-weight: 600; line-height: 1.75; margin-bottom: 16px; white-space: pre-wrap; color: var(--text); }

.opt {
  display: flex; align-items: center; gap: 11px;
  width: 100%; text-align: left;
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: 9px; min-height: 50px; font-size: 15px;
  transition: border-color .15s ease, background .15s ease, transform .08s ease;
}
.opt:active { transform: scale(.992); }
.opt .key {
  flex: none; width: 28px; height: 28px; border-radius: 9px;
  background: var(--primary-soft); color: var(--primary);
  font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 13px;
  transition: all .15s ease;
}
.opt.selected { border-color: var(--primary); background: var(--primary-soft); }
.opt.correct { border-color: var(--green); background: var(--green-soft); }
.opt.wrong { border-color: var(--red); background: var(--red-soft); }
.opt.disabled { pointer-events: none; opacity: .9; }
.opt .key.correct { background: var(--green); color: #fff; }
.opt .key.wrong { background: var(--red); color: #fff; }

/* 判断题：正确 / 错误 并排 */
.judge-row { display: flex; gap: 10px; }
.judge-row .opt { margin-bottom: 0; justify-content: center; font-weight: 600; }

/* 上一题 / 下一题（左右各半；上一题为中性色，与主色「下一题」区分） */
.qnav { display: flex; gap: 10px; margin: 12px 0 2px; }
.qnav .btn { flex: 1 1 0; min-width: 0; }
.btn.qnav-prev {
  background: var(--surface-2); color: var(--text-2);
  border: 1.5px solid var(--border-strong); box-shadow: none;
}
.btn.qnav-prev:active { background: var(--surface-3); }

.feedback {
  border-radius: var(--radius-sm); padding: 14px; margin-top: 6px; font-size: 14px;
  box-shadow: var(--shadow-sm);
}
.feedback.ok { background: var(--green-soft); color: var(--green-ink); }
.feedback.no { background: var(--red-soft); color: var(--red-ink); }
.feedback .exp { margin-top: 8px; opacity: .9; line-height: 1.7; }

.fill-input { font-size: 16px; padding: 13px; margin-bottom: 10px; }

/* 填空题：每空一个就地输入框 */
.fill-inline {
  display: inline-block; min-width: 86px; width: 140px; max-width: 46%;
  font-size: 16px; padding: 6px 9px; margin: 4px 3px; vertical-align: baseline;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.fill-inline:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.fill-inline.correct { border-color: var(--green); background: var(--green-soft); color: var(--green-ink); }
.fill-inline.wrong { border-color: var(--red); background: var(--red-soft); color: var(--red-ink); }
.fill-inline:disabled { opacity: .85; cursor: default; }
.fill-hint { font-size: 12px; color: var(--text-2); margin: 8px 0 2px; }

.fill-blanks { margin: 6px 0; }
.fill-blanks .fill-part { display: block; margin: 4px 0; }
.fill-blank { display: inline-block; }

/* 简答题作答 */
.essay-input {
  width: 100%; box-sizing: border-box; font-size: 16px; line-height: 1.7;
  padding: 13px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); color: var(--text); resize: vertical;
  margin-bottom: 10px; font-family: inherit;
}
.essay-input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.essay-ref {
  background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm); padding: 12px 14px; margin: 4px 0 12px; line-height: 1.8;
}
.essay-ref .ref-title { font-size: 12px; font-weight: 800; color: var(--primary); margin-bottom: 4px; }
.self-rate { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; color: var(--text-2); }
.hidden { display: none !important; }
.fill-part { display: inline-block; padding: 2px 9px; border-radius: 8px; margin: 2px; font-weight: 700; }
.fill-part.ok { background: var(--green-soft); color: var(--green-ink); }
.fill-part.no { background: var(--red-soft); color: var(--red-ink); }
.fill-part.miss { background: var(--amber-soft); color: var(--amber-ink); }

.quiz-end { text-align: center; padding: 26px 0; }
.quiz-end .score {
  font-size: 52px; font-weight: 900; letter-spacing: -1px;
  background: var(--grad-primary); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.quiz-end .sub { color: var(--muted); margin: 8px 0 22px; }

/* ===== 卡片视图 ===== */
.card-face {
  min-height: 230px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 26px 20px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 18px; line-height: 1.85; color: var(--text);
  cursor: pointer; margin-bottom: 16px;
  transition: transform .15s ease, box-shadow .2s ease;
}
.card-face:active { transform: scale(.985); }
.card-face .hint { color: var(--muted); font-size: 13px; margin-top: 16px; }
.rate-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rate-btn { min-height: 54px; border-radius: var(--radius-sm); font-weight: 700; font-size: 13px; transition: transform .08s ease, filter .15s ease; }
.rate-btn:active { transform: scale(.95); }
.rate-btn.r0 { background: var(--red-soft); color: var(--red-ink); }
.rate-btn.r1 { background: var(--amber-soft); color: var(--amber-ink); }
.rate-btn.r2 { background: var(--green-soft); color: var(--green-ink); }
.rate-btn.r3 { background: var(--blue-soft); color: var(--blue-ink); }
body.dark .rate-btn.r0 { background: #3a1414; color: #fca5a5; }
body.dark .rate-btn.r1 { background: #3a2a08; color: #fcd34d; }
body.dark .rate-btn.r2 { background: #0b2e22; color: #6ee7b7; }
body.dark .rate-btn.r3 { background: #122245; color: #93c5fd; }

/* ===== 错题视图 ===== */
.wrong-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 13px 14px; margin-bottom: 8px;
}
.wrong-item .meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }

/* ===== 统计视图 ===== */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 14px 8px; text-align: center;
}
.stat-cell .num { font-size: 23px; font-weight: 900; color: var(--primary); letter-spacing: -.5px; }
.stat-cell .lbl { font-size: 11px; color: var(--muted); margin-top: 3px; }
.stat-cell.span3 { grid-column: span 3; }
.stat-grid.bigger { grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-grid.bigger .stat-cell { padding: 17px 6px; border-radius: var(--radius); }
.stat-grid.bigger .stat-cell .num { font-size: 26px; }
.stat-grid.bigger .stat-cell .lbl { font-size: 12px; margin-top: 4px; }

/* 章节正确率 */
.acc-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13px; }
.acc-row .acc-name { width: 92px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.acc-row .acc-track { flex: 1; height: 9px; background: var(--border); border-radius: var(--radius-pill); overflow: hidden; }
.acc-row .acc-fill { height: 100%; background: var(--grad-primary); border-radius: var(--radius-pill); transition: width .4s ease; }
.acc-row .acc-val { width: 42px; flex: none; text-align: right; color: var(--muted); }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 13px; }
.bar-row .name { width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: none; color: var(--text-2); }
.bar-row .track { flex: 1; height: 9px; background: var(--border); border-radius: var(--radius-pill); overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--grad-primary); border-radius: var(--radius-pill); transition: width .3s ease; }
.bar-row .val { width: 42px; text-align: right; color: var(--muted); flex: none; }
.week { display: flex; gap: 6px; align-items: flex-end; height: 76px; padding: 8px 0; }
.week .day { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.week .col { width: 100%; background: var(--primary-soft); border-radius: 5px 5px 0 0; min-height: 2px; transition: height .3s ease; }
.week .lbl { font-size: 10px; color: var(--muted); }
body.dark .week .col { background: var(--primary-soft); }

/* ===== 统计·子页切换（墨墨式分段控件） ===== */
.stat-tabs {
  display: flex; gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px; margin-bottom: 12px;
}
.stat-tab {
  flex: 1; padding: 9px 4px;
  border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 600; color: var(--muted);
  transition: all .18s ease;
}
.stat-tab.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); font-weight: 800; }

/* 曲线头部三指标 */
.curve-head { display: flex; gap: 8px; margin-bottom: 10px; }
.curve-head .ch-item {
  flex: 1; text-align: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 4px;
}
.curve-head .ch-num { font-size: 20px; font-weight: 900; color: var(--primary); letter-spacing: -.5px; }
.curve-head .ch-lbl { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* 图例 */
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.legend .lg { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* 学习情况·小范围切换 */
.seg-mini { display: inline-flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 3px; }
.seg-mini-btn { padding: 5px 12px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; color: var(--muted); transition: all .15s ease; }
.seg-mini-btn.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

/* SVG 图表类（CSS 变量可随深浅主题切换） */
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis { fill: var(--muted); }
.chart-line-user { stroke: var(--primary); stroke-width: 2.4; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.chart-line-std { stroke: var(--muted); stroke-width: 1.6; fill: none; stroke-dasharray: 4 3; opacity: .7; }
.chart-area { fill: url(#fcg); }
.fcg-stop-1 { stop-color: var(--primary); stop-opacity: .30; }
.fcg-stop-2 { stop-color: var(--primary); stop-opacity: 0; }
.qbg-1 { stop-color: var(--primary); stop-opacity: .95; }
.qbg-2 { stop-color: var(--primary-2); stop-opacity: .55; }

/* ===== 弹窗 ===== */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-mask.hidden { display: none; }
/* 删除确认弹窗在卡片编辑器（z-index:300）之上，否则会被不透明编辑器挡住看不见 */
#ce-confirm { z-index: 450; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  width: 100%; max-width: 560px; max-height: 88vh;
  overflow-y: auto;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px 16px calc(18px + var(--safe-bottom));
  box-shadow: var(--shadow-lg);
  animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(34px); opacity: .55; } to { transform: none; opacity: 1; } }
.modal h2 {
  font-size: 17px; font-weight: 800; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between;
  letter-spacing: .2px;
}
.modal h2 .close {
  color: var(--muted); font-size: 20px; padding: 2px 10px; border-radius: 8px;
  transition: background .15s ease, color .15s ease;
}
.modal h2 .close:active { background: var(--surface-3); color: var(--text); }
.mtab { display: flex; gap: 8px; margin-bottom: 12px; }
.mtab button {
  flex: 1; padding: 10px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--muted);
  transition: all .15s ease;
}
.mtab button.on { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.import-area { margin-bottom: 10px; }
.import-area textarea { min-height: 170px; resize: vertical; line-height: 1.6; }
.preview-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px; margin: 12px 0; font-size: 13px;
  max-height: 230px; overflow-y: auto; line-height: 1.7;
}
.preview-box .err { color: var(--red); }
.preview-box .ok-line { color: var(--green); }

/* ===== Toast ===== */
#toast {
  position: fixed; left: 50%;
  bottom: calc(82px + var(--safe-bottom));
  transform: translateX(-50%) translateY(10px);
  background: rgba(15,23,42,.94);
  color: #fff; padding: 11px 20px;
  border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 500;
  z-index: 200; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
  max-width: 86vw; text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.30);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }

/* ===== 题库·题目行可展开 / 详情 / 收藏 ===== */
.qwrap { margin: 0 0 8px 14px; }
.qitem:active { background: var(--surface-2); }
.qitem .arrow.sm { display: inline-block; transition: transform .18s ease; color: var(--muted); font-size: 11px; flex: none; }
.qitem.open .arrow.sm { transform: rotate(90deg); color: var(--primary); }

.fav {
  flex: none; width: 34px; height: 34px; border-radius: 10px;
  font-size: 18px; line-height: 1; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .15s ease;
}
.fav:active { transform: scale(.92); }
.fav.on { color: #d97706; background: #fef3c7; border-color: #fcd34d; }

.q-detail { margin: 0 0 4px; }
.q-detail-inner {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 13px 14px; margin: 0 2px;
}
.opt-ans {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); margin-bottom: 7px; font-size: 14px;
}
.opt-ans .key {
  flex: none; width: 26px; height: 26px; border-radius: 8px;
  background: var(--primary-soft); color: var(--primary); font-weight: 800;
  display: flex; align-items: center; justify-content: center; font-size: 12px;
}
.opt-ans.right { border-color: var(--green); background: var(--green-soft); }
.opt-ans.right .key { background: var(--green); color: #fff; }
.ans { font-size: 14px; line-height: 1.8; margin-bottom: 6px; color: var(--text); }
.ans .lbl { font-weight: 800; color: var(--primary); margin-right: 4px; }
.ans:last-of-type { margin-bottom: 0; }
.exp { font-size: 13px; color: var(--text-2); margin-top: 8px; line-height: 1.7; }

/* 个人操作区：笔记 + 收藏 */
.perso { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 12px; }
.perso-label {
  display: flex; align-items: center; gap: 6px; width: 100%;
  font-size: 13px; font-weight: 700; color: var(--primary);
  background: none; border: none; padding: 0; margin-bottom: 7px;
  font-family: inherit; text-align: left; cursor: pointer;
}
.perso-label .ico-note { flex: none; }
.perso-arrow { font-size: 11px; transition: transform .15s; transform: rotate(90deg); }
.perso.collapsed .perso-arrow { transform: rotate(0deg); }
.perso.collapsed .perso-label { margin-bottom: 0; }
.perso.collapsed .perso-body { display: none; }
.note-input {
  width: 100%; box-sizing: border-box; font-size: 16px; line-height: 1.7;
  padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); resize: vertical; min-height: 72px;
  font-family: inherit; margin-bottom: 9px;
}
.note-input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.perso-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.fav2 { min-width: 96px; }
.fav2.on { color: #b45309; border-color: #fcd34d; background: #fef3c7; }

/* 个人视图·子导航 */
.psubnav {
  display: flex; gap: 6px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  padding: 4px; margin-bottom: 12px;
}
.psub {
  flex: 1; padding: 9px 4px; border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 600; color: var(--muted);
  transition: all .18s ease;
}
.psub.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); font-weight: 800; }

/* 刷题·题目头部（题型 + 收藏） */
.qhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.qtype-badge {
  display: inline-block; padding: 3px 11px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 700; background: var(--primary-soft); color: var(--primary-dark);
}
.quiz-perso { margin-top: 14px; }

/* 卡片·备注 */
.card-note { margin-top: 16px; }

/* 深色主题下收藏高亮对比 */
body.dark .fav.on { color: #fbbf24; background: #3a2a08; border-color: #92400e; }
body.dark .fav2.on { color: #fbbf24; background: #3a2a08; border-color: #92400e; }

/* ===== 个人页·排序 ===== */
.sort-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.sort-row .sort-label { font-size: 13px; color: var(--muted); }
.sort-chip {
  padding: 6px 14px; border-radius: var(--radius-pill);
  border: 1.5px solid var(--border); background: var(--surface);
  font-size: 13px; color: var(--muted); font-weight: 600;
  transition: all .15s ease;
}
.sort-chip.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 700; }

/* ===== 个人页·分组卡片 ===== */
.group-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  margin-bottom: 8px; overflow: hidden;
  transition: border-color .15s ease, box-shadow .2s ease;
}
.group-head { display: flex; align-items: center; gap: 9px; padding: 13px 14px; cursor: pointer; }
.group-head .g-ico { font-size: 17px; flex: none; }
.group-head .g-name { flex: 1; min-width: 0; font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.group-head .g-count { font-size: 12px; color: var(--muted); flex: none; }
.group-head .arrow { color: var(--muted); flex: none; transition: transform .18s ease; }
.group-card.open .group-head .arrow { transform: rotate(90deg); color: var(--primary); }
.group-head .del-grp { flex: none; color: var(--muted); padding: 4px 8px; border-radius: 8px; font-size: 15px; }
.group-head .del-grp:active { color: var(--red); background: var(--red-soft); }
.group-body { padding: 0 10px 10px; }
.group-body .qwrap { margin-left: 0; }
.group-empty { font-size: 13px; color: var(--muted); padding: 6px 4px 8px; }
.group-name-input {
  flex: 1; min-width: 0; font-size: 16px; font-weight: 700; /* ≥16px 防 iOS 聚焦放大 */
  padding: 5px 9px; border: 1.5px solid var(--primary); border-radius: 9px;
  background: var(--surface); color: var(--text); box-shadow: var(--ring);
}

/* ===== 长按拖动分组 ===== */
.qwrap[data-drag], .qwrap[data-drag] * {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;               /* 关键：压掉 iOS 长按的蓝色选择菜单 */
}
.qwrap[data-drag] .qitem { touch-action: manipulation; } /* 保留滚动、禁用双击缩放 */
.qwrap[data-drag] textarea,
.qwrap[data-drag] input {
  -webkit-user-select: text; user-select: text;   /* 笔记框仍需可选中编辑 */
  touch-action: auto;
}
.qitem.dragging { opacity: .4; }
.qitem.drop-target { border-color: var(--primary); background: var(--primary-soft); }
.group-card.drop-target { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft), var(--shadow-lg); }
.drag-ghost {
  position: fixed; z-index: 999; pointer-events: none;
  width: 260px; max-width: 78vw;
  transform: translate(-50%, -50%) rotate(-1.5deg) scale(1.02);
  box-shadow: var(--shadow-lg); border-radius: var(--radius-sm);
  opacity: .96;
}
.drag-ghost .q-detail { display: none !important; }
body.dnd-active { cursor: grabbing; }
body.dnd-active * { cursor: grabbing !important; }

/* ===== 划词标注（刷题页） ===== */
.qstem, .opt span[data-mk] {
  -webkit-user-select: text; user-select: text;
  -webkit-touch-callout: default;
}
/* 四个样式位互不排斥：由 richtext.js 由外到内嵌套 <b> > <span u> > <span fc> > <mark hl> */
.mk-hl { color: inherit; padding: 0 1px; border-radius: 3px; }
.mk-u  { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.mk-b  { font-weight: 800; }
.mk-red{ color: var(--red); font-weight: 700; }   /* 旧数据兜底，已归一化为 .fc-r */
/* 高亮五色 / 字色五色：只负责自己的那一层，叠加时互不影响 */
.hl-y { background: #fde68a; } .hl-g { background: #bbf7d0; } .hl-b { background: #bfdbfe; }
.hl-p { background: #fbcfe8; } .hl-o { background: #fed7aa; }
.fc-r { color: #dc2626; } .fc-o { color: #ea580c; } .fc-g { color: #16a34a; }
.fc-b { color: #2563eb; } .fc-p { color: #9333ea; }
/* 夜间：高亮换深底（不指定字色，保证叠字色时仍以字色为准） */
body.dark .hl-y { background: #5c430a; }
body.dark .hl-g { background: #14532d; }
body.dark .hl-b { background: #1e3a8a; }
body.dark .hl-p { background: #831843; }
body.dark .hl-o { background: #7c2d12; }
body.dark .fc-r { color: #f87171; }
body.dark .fc-o { color: #fb923c; }
body.dark .fc-g { color: #4ade80; }
body.dark .fc-b { color: #60a5fa; }
body.dark .fc-p { color: #c084fc; }
#mkbar {
  position: fixed; z-index: 200;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 5px; box-shadow: var(--shadow-lg);
  max-width: calc(100vw - 20px);
}
#mkbar.hidden { display: none; }
.mk-row { display: flex; gap: 2px; }
#mkbar button {
  border: none; background: transparent; color: var(--text);
  font-size: 13px; font-weight: 600; padding: 7px 10px; border-radius: 8px;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
#mkbar button:active { background: var(--primary-soft); color: var(--primary); }
#mkbar .mk-row button[data-mkstyle="hl"] { color: #b45309; }
#mkbar .mk-row button[data-mkstyle="fc"] { color: var(--red); }
#mkbar .mk-row button[data-mkstyle="u"] { text-decoration: underline; text-underline-offset: 3px; }
#mkbar .mk-row button[data-mkstyle="b"] { font-weight: 800; }
/* 色板行 */
.mk-pal {
  display: flex; gap: 12px; justify-content: center;
  margin-top: 5px; padding-top: 7px; border-top: 1px solid var(--border);
}
.mk-pal.hidden { display: none; }
#mkbar .mk-dot {
  width: 26px; height: 26px; padding: 0; border-radius: 50%;
  border: 2px solid var(--border);
}
#mkbar .mk-dot:active { transform: scale(.9); }
/* 色点颜色必须带 #mkbar 前缀：否则被上面 #mkbar button 的 background:transparent（ID 特异性更高）盖成白色 */
#mkbar .sw-y { background: #fde68a; } #mkbar .sw-g { background: #bbf7d0; } #mkbar .sw-b { background: #bfdbfe; }
#mkbar .sw-p { background: #fbcfe8; } #mkbar .sw-o { background: #fed7aa; }
#mkbar .sw-r { background: #ef4444; } #mkbar .sw-o2 { background: #f97316; } #mkbar .sw-g2 { background: #22c55e; }
#mkbar .sw-b2 { background: #3b82f6; } #mkbar .sw-p2 { background: #a855f7; }
#mkbar .mk-dot { box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }   /* 浅色点在白底上也能看出轮廓 */

/* ===== 自定义卡片编辑器 ===== */
#ce-mask {
  position: fixed; inset: 0; z-index: 300;
  display: flex; flex-direction: column;
  background: var(--bg);
  padding: calc(10px + var(--safe-top)) 12px calc(10px + var(--safe-bottom));
}
#ce-mask.hidden { display: none; }
.ce-top {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.ce-back, .ce-save {
  border: none; background: transparent; color: var(--primary);
  font-size: 17px; font-weight: 700; padding: 6px 10px; border-radius: 10px;
}
.ce-save { color: #fff; background: var(--grad-primary); }
.ce-del { color: var(--red); font-size: 15px; font-weight: 700; padding: 6px 10px; border-radius: 10px; background: transparent; border: none; }
.ce-del[hidden] { display: none; }
.modal-sub { color: var(--muted); font-size: 13px; line-height: 1.6; margin: -6px 0 16px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }
.ce-tabs { display: flex; background: var(--surface-2); border-radius: var(--radius-pill); padding: 3px; }
.ce-tabs button {
  border: none; background: transparent; color: var(--muted);
  font-size: 14px; font-weight: 700; padding: 6px 18px; border-radius: var(--radius-pill);
}
.ce-tabs button.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.ce-meta {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.ce-field { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); flex: 1; min-width: 0; }
.ce-field input {
  flex: 1 1 0; min-width: 0; width: 0; font-size: 16px; padding: 7px 10px;   /* width:0：掐断 iOS 对 input 的固有宽度，防止整行撑出屏幕 */
}
.ce-field.ce-order { flex: 0 0 92px; }
#ce-star {
  border: 1.5px solid var(--border); background: var(--surface); color: var(--muted);
  font-size: 19px; width: 38px; height: 38px; border-radius: 10px; line-height: 1;
}
#ce-star.on { color: #f59e0b; border-color: #f59e0b; background: rgba(245,158,11,.10); }
.ce-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-top: 10px; }
.ce-side-label { font-size: 12px; font-weight: 700; color: var(--muted); margin: 8px 2px 5px; }
.ce-ta { font-size: 16px; line-height: 1.7; }   /* ≥16px：iOS 聚焦不缩放页面 */
.ce-tools {
  display: flex; gap: 4px; padding-top: 8px; border-top: 1px solid var(--border);
}
.ce-tools button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: none; background: transparent; color: var(--text);
  font-size: 11px; padding: 6px 0; border-radius: 10px;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.ce-tools button:active { background: var(--primary-soft); color: var(--primary); }
.ce-ico { font-size: 15px; font-weight: 800; line-height: 1.2; }
.ce-i-hl { background: #fde68a; color: #7c4a03; border-radius: 4px; padding: 0 5px; }
.ce-i-b  { font-weight: 900; }
.ce-i-u  { text-decoration: underline; text-decoration-thickness: 2px; }
/* 编辑器与预览里的星标 / 挖空 / 图片 */
.ce-star-mark { color: #f59e0b; margin-right: 4px; font-size: .95em; }
.cloze {
  background: var(--surface-2); color: transparent; border-radius: 4px;
  padding: 0 4px; cursor: pointer; min-width: 2em; display: inline-block; text-align: center;
}
.cloze.revealed { color: var(--primary); background: var(--primary-soft); font-weight: 700; }
.card-img, #ce-prev .card-img {
  display: block; max-width: 100%; max-height: 300px; width: auto;
  margin: 8px auto; border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.ce-prev-card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 16px; font-size: 15px; line-height: 1.75;
}
.ce-prev-div { margin: 12px 0; border-top: 1px dashed var(--border); }
.ce-prev-back { color: var(--muted); }
/* 复习页「编辑此卡」行 */
.card-tools-row { display: flex; justify-content: flex-end; margin-bottom: 8px; }

/* ===== 选卡页（卡片列表 · 自选加入记忆） ===== */
.cp-wrap { padding-bottom: 6px; }
.cp-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cp-title { font-size: 16px; font-weight: 800; color: var(--text); }
.cp-search {
  width: 100%; box-sizing: border-box; font-size: 16px;  /* 16px 防 iOS 聚焦缩放 */
  padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--text); outline: none;
}
.cp-search:focus { border-color: var(--primary); background: var(--surface); }
.cp-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 2px 10px; border-top: 1px dashed var(--border); margin-top: 4px;
}
.cp-all { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.cp-all input { width: 18px; height: 18px; accent-color: var(--primary); }
.cp-count { font-size: 12px; color: var(--muted); margin-right: auto; }

.cp-list { display: flex; flex-direction: column; gap: 8px; max-height: 52vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.cp-row {
  flex: none;   /* 关键：flex 列容器里默认会压缩子项，导致每行被压扁、文字切半 */
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); overflow: hidden;
}
.cp-row.on, .cp-row:has(.cp-ck:checked) { border-color: var(--primary); background: var(--primary-soft); }
.cp-line { display: flex; align-items: center; }
.cp-main { display: flex; align-items: flex-start; gap: 9px; flex: 1; padding: 10px 4px 10px 12px; min-width: 0; }
.cp-main input.cp-ck { width: 18px; height: 18px; margin-top: 2px; flex: none; accent-color: var(--primary); }
.cp-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.cp-front {
  font-size: 14px; line-height: 1.45; color: var(--text); font-weight: 600;
  word-break: break-word; white-space: normal;   /* 完整展示，不截断 */
}
.cp-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cp-b {
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: var(--radius-pill); white-space: nowrap;
}
.cp-b.due   { background: var(--red-soft);   color: var(--red-ink); }
.cp-b.new   { background: var(--blue-soft);  color: var(--blue-ink); }
.cp-b.soon  { background: var(--surface-3);  color: var(--text-2); }
.cp-ch { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.cp-peek-btn {
  flex: none; width: 40px; align-self: stretch; border: none; border-left: 1px solid var(--border);
  background: transparent; color: var(--muted); font-size: 15px; -webkit-tap-highlight-color: transparent;
}
.cp-peek-btn:active { background: var(--surface-3); }
.cp-peek { padding: 4px 12px 12px; border-top: 1px dashed var(--border); background: var(--surface); }
.cp-peek .cp-meta { margin-bottom: 8px; }
.cp-peek .cp-ch { max-width: none; white-space: normal; }
.cp-peek-face { position: relative; font-size: 14px; line-height: 1.6; color: var(--text); padding-top: 8px; }
.cp-peek-face + .cp-peek-face { margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--border); }
.cp-peek-face .card-img { max-width: 100%; border-radius: 10px; }
.cp-peek-tag {
  display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .5px;
  color: var(--primary); background: var(--primary-soft); padding: 2px 6px; border-radius: 6px; margin-right: 6px;
}
body.dark .cp-row.on, body.dark .cp-row:has(.cp-ck:checked) { background: rgba(20,184,166,.14); }
body.dark .cp-b.soon { background: var(--surface); color: var(--muted); }
/* 全屏图片查看 */
.imgview {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(0,0,0,.88); display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 16px;
}
.imgview.hidden { display: none; }
.imgview img { max-width: 100%; max-height: 82vh; border-radius: 8px; }
.imgview-tip { color: rgba(255,255,255,.65); font-size: 13px; margin-top: 14px; }

/* ===== 图片遮罩卡（一图一卡，多框同卡） ===== */
/* 遮罩框的坐标是 0~1 相对值 → 换成百分比定位，容器宽度怎么变都不会跑偏 */
.occ-wrap {
  position: relative; display: inline-block; max-width: 100%;
  line-height: 0; touch-action: none; -webkit-user-select: none; user-select: none;
}
/* 子元素也要关掉手势：否则手指落在图片本身时页面还是会跟着滚 */
.occ-wrap * { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.occ-box {
  position: absolute; display: block; border-radius: 4px;
  background: var(--primary); opacity: 1;   /* 遮蔽态：完全不透明，彻底盖住内容 */
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
  cursor: pointer;
}
body.dark .occ-box { background: var(--primary); }
/* 揭开态：不完全透明 —— 高透明主题色淡染，答案看得清，但仍能看出这里被遮过 */
.occ-box.revealed {
  opacity: .15; background: var(--primary);
  box-shadow: inset 0 0 0 1.5px var(--primary);
}
/* 遮罩编辑器浮层 */
#occ-mask {
  position: fixed; inset: 0; z-index: 350;
  display: flex; flex-direction: column; background: var(--bg);
  padding: calc(10px + var(--safe-top)) 12px calc(10px + var(--safe-bottom));
}
#occ-mask.hidden { display: none; }
.occ-top { display: flex; align-items: center; justify-content: space-between; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.occ-back, .occ-done { border: none; background: transparent; color: var(--primary); font-size: 17px; font-weight: 700; padding: 6px 10px; border-radius: 10px; }
.occ-done { color: #fff; background: var(--grad-primary); }
.occ-title { font-size: 15px; font-weight: 700; }
.occ-stage { flex: 1; min-height: 0; overflow: auto; display: flex; align-items: center; justify-content: center; touch-action: none; }
#occ-img { display: block; max-width: 100%; max-height: 62vh; border-radius: var(--radius-sm); }
#occ-wrap .occ-box { border: 1.5px solid rgba(255,255,255,.35); }
.occ-rs {
  position: absolute; right: -11px; bottom: -11px; width: 26px; height: 26px;
  border-radius: 50%; background: var(--primary); border: 2px solid #fff; line-height: 1;
}
.occ-del {
  position: absolute; right: -9px; top: -9px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; color: var(--red); font-size: 14px; line-height: 20px; font-weight: 700;
  text-align: center; border: 1px solid var(--border);
}
#occ-wrap.previewing .occ-box { opacity: .15; background: var(--primary); box-shadow: inset 0 0 0 1.5px var(--primary); }
#occ-wrap.previewing .occ-rs, #occ-wrap.previewing .occ-del { display: none; }
.occ-tools { padding-top: 8px; border-top: 1px solid var(--border); }
.occ-hint { font-size: 12px; color: var(--muted); line-height: 1.6; }
.occ-row { display: flex; gap: 8px; margin-top: 8px; }
.occ-row .btn { flex: 1; }
/* 多图时选一张 */
.occ-pick { position: fixed; inset: 0; z-index: 360; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; padding: 12px; }
.occ-pick.hidden { display: none; }
.occ-pick-box { background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 420px; padding: 14px; box-shadow: var(--shadow-lg); max-height: 70vh; overflow: auto; }
.occ-pick-title { font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.occ-pick-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 8px; margin-bottom: 8px; }
.occ-pick-item img { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; }
.occ-pick-item span { font-size: 13px; color: var(--muted); }

/* ===== 图片裁剪层（仿系统相册：黑底 + 白框拖拽 + 比例 + 旋转） ===== */
#crop-mask {
  position: fixed; inset: 0; z-index: 370;
  display: flex; flex-direction: column;
  background: #101418; color: #fff;
  padding: calc(10px + var(--safe-top)) 12px calc(10px + var(--safe-bottom));
}
#crop-mask.hidden { display: none; }
.crop-top {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,.14);
}
.crop-back, .crop-done {
  border: none; background: transparent; color: #fff;
  font-size: 17px; font-weight: 700; padding: 6px 12px; border-radius: 10px;
}
.crop-done { background: var(--grad-primary); }
.crop-title { font-size: 15px; font-weight: 700; }
.crop-stage {
  flex: 1; min-height: 0; overflow: auto;
  display: flex; align-items: center; justify-content: center;
  padding: 14px 0; touch-action: none;
}
.crop-wrap {
  position: relative; display: inline-block; max-width: 100%;
  line-height: 0; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.crop-wrap * { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#crop-img { display: block; max-width: 100%; max-height: 56vh; border-radius: 4px; }
#crop-rect {
  position: absolute; display: block; border-radius: 4px;
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.45);   /* 框外压暗，聚焦裁剪区 */
  cursor: move;
}
.crop-rs {
  position: absolute; right: -13px; bottom: -13px; width: 26px; height: 26px;
  border-radius: 50%; background: var(--primary); border: 2px solid #fff; line-height: 1;
}
.crop-tools { padding-top: 10px; border-top: 1px solid rgba(255,255,255,.14); }
.crop-row { display: flex; align-items: center; gap: 8px; }
.crop-chip {
  flex: 1; border: 1px solid rgba(255,255,255,.28); background: rgba(255,255,255,.06);
  color: #fff; font-size: 13px; font-weight: 600; padding: 9px 0; border-radius: 9px;
  -webkit-user-select: none; user-select: none;
}
.crop-chip.on { border-color: var(--primary); color: var(--primary); background: rgba(255,255,255,.10); }
.crop-chip.crop-rot { flex: 0 0 auto; padding: 9px 14px; }
@media (prefers-reduced-motion: reduce) {
  #mkbar, .ce-tools button, #btn-theme .ico-sun { transition: none; animation: none; }
}

/* ===== LaTeX 公式（KaTeX）===== */
.katex { font-size: 1.06em; }   /* 与正文字号自然融合 */
.katex-display {
  margin: 8px 0; padding: 2px 0;
  overflow-x: auto; overflow-y: hidden;   /* 窄屏长公式可横向滑动 */
}
