/* 视觉基础：变量、组件、宽屏布局（由设计方案整理而来，后面的 app 专用样式接在 app.css 里） */
:root {
  color-scheme: light;

  /* 1. 字体栈（零外链，覆盖 iOS / Android / Windows 中文字体与等宽数字） */
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "HarmonyOS Sans SC", "MiSans", "Noto Sans CJK SC", "Microsoft YaHei UI",
    "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  --font-num: "SF Pro Display", "DIN Alternate", "Bahnschrift", "Segoe UI Variable Display",
    var(--font-sans);
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;

  /* 2. 背景层级（由深到浅建立空间，避免千篇一律白框） */
  --bg-canvas: #f3f1eb;      /* 页面画布底 */
  --bg-subtle: #e9e6dd;      /* 下沉槽区：解析内底、分段轨、顺延区 */
  --bg-surface: #fcfbf8;     /* 主内容卡片 */
  --bg-elevated: #ffffff;    /* 顶层浮层、按下高亮、激活滑块 */
  --bg-scrim: rgba(24, 22, 19, 0.42);

  /* 3. 文字层级 */
  --text-primary: #1c1a17;   /* 主正文、题干 */
  --text-secondary: #57534c; /* 辅助说明、选项解析 */
  --text-tertiary: #78736a;  /* 元信息、次要标签（对比度仍 ≥4.5:1 在浅卡上） */
  --text-inverse: #faf9f5;   /* 深色实底按钮文字 */

  /* 4. 主色（靛蓝：交互、焦点、进行中） */
  --brand: #294c84;
  --brand-solid: #294c84;
  --brand-soft: #e8eef7;
  --brand-border: #b8c9e4;

  /* 5. 强调色（暖赭金：倒计时、连续打卡、重要星标） */
  --accent: #8f5c10;
  --accent-soft: #f6eedc;
  --accent-border: #dfd0ac;

  /* 6. 语义色（低饱和，必须配合图标/文字/线型） */
  --ok: #1f6e4b;             /* 对 / 强 / 完成 */
  --ok-soft: #e6f2ec;
  --ok-border: #b3d7c6;

  --warn: #946112;           /* 警示 / 中 / 顺延 */
  --warn-soft: #f7efe0;
  --warn-border: #e0cb9e;

  --err: #ae3b32;            /* 错 / 弱 / 常错 */
  --err-soft: #f8eae8;
  --err-border: #e2b8b4;

  /* 7. 边框 */
  --border-subtle: #e6e2d8;
  --border-default: #d5cfc3;
  --border-strong: #b6afa0;

  /* 8. 圆角 */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  /* 9. 阴影（克制微影，不靠重投影区分层级） */
  --shadow-sm: 0 1px 2px rgba(28, 26, 23, 0.05);
  --shadow-md: 0 6px 20px rgba(28, 26, 23, 0.08);
  --shadow-nav: 0 -1px 0 var(--border-subtle), 0 -4px 16px rgba(28, 26, 23, 0.04);

  /* 10. 间距与触控基准 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --touch-min: 44px;
  --nav-h: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --container-max: 1160px;

  /* 11. 字号阶梯（适配移动端中文阅读与数学公式） */
  --text-xs: 0.75rem;        /* 12px：标签、底栏文字 */
  --text-sm: 0.84375rem;     /* 13.5px：次级信息、元标签 */
  --text-base: 0.9375rem;    /* 15px：常规正文、清单项 */
  --text-md: 1rem;           /* 16px：题干正文、选项 */
  --text-lg: 1.125rem;       /* 18px：卡片/区块标题 */
  --text-xl: 1.375rem;       /* 22px：页面主标题 */
  --text-2xl: 1.75rem;       /* 28px：统计数字 */
  --text-kpi: clamp(2.5rem, 8vw, 3.5rem); /* 番茄钟/主分数 */
}

/* 深色变量复用（支持系统自动切换 + 手动 data-theme="dark"） */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg-canvas: #131210;
    --bg-subtle: #1a1916;
    --bg-surface: #201e1b;
    --bg-elevated: #2a2723;
    --bg-scrim: rgba(0, 0, 0, 0.65);

    --text-primary: #ece8df;
    --text-secondary: #aca69b;
    --text-tertiary: #8c867c;
    --text-inverse: #141311;

    --brand: #7ca3e8;
    --brand-solid: #3d64ac;
    --brand-soft: #1d283b;
    --brand-border: #334a73;

    --accent: #dfa84d;
    --accent-soft: #2e2517;
    --accent-border: #524022;

    --ok: #4ec48b;
    --ok-soft: #172b22;
    --ok-border: #28523e;

    --warn: #e0ad52;
    --warn-soft: #2d2415;
    --warn-border: #554222;

    --err: #e3796f;
    --err-soft: #2f1c1a;
    --err-border: #5e322e;

    --border-subtle: #2b2824;
    --border-default: #3a3630;
    --border-strong: #524d45;

    --shadow-sm: none;
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-nav: 0 -1px 0 var(--border-subtle);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-canvas: #131210;
  --bg-subtle: #1a1916;
  --bg-surface: #201e1b;
  --bg-elevated: #2a2723;
  --bg-scrim: rgba(0, 0, 0, 0.65);

  --text-primary: #ece8df;
  --text-secondary: #aca69b;
  --text-tertiary: #8c867c;
  --text-inverse: #141311;

  --brand: #7ca3e8;
  --brand-solid: #3d64ac;
  --brand-soft: #1d283b;
  --brand-border: #334a73;

  --accent: #dfa84d;
  --accent-soft: #2e2517;
  --accent-border: #524022;

  --ok: #4ec48b;
  --ok-soft: #172b22;
  --ok-border: #28523e;

  --warn: #e0ad52;
  --warn-soft: #2d2415;
  --warn-border: #554222;

  --err: #e3796f;
  --err-soft: #2f1c1a;
  --err-border: #5e322e;

  --border-subtle: #2b2824;
  --border-default: #3a3630;
  --border-strong: #524d45;

  --shadow-sm: none;
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-nav: 0 -1px 0 var(--border-subtle);
}

/* === 基础复位 === */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

/* === 1. 底部标签栏（移动端固定 + 避开 iPhone 安全区） === */
.tab-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg-surface);
  box-shadow: var(--shadow-nav);
  padding: var(--space-1) var(--space-2) max(var(--space-1), var(--safe-bottom));
}
.tab-item {
  min-height: var(--nav-h);
  min-width: var(--touch-min);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
  transition: color 0.15s, background-color 0.15s;
}
.tab-icon {
  width: 22px; height: 22px;
  padding: 3px 14px;
  box-sizing: content-box;
  border-radius: var(--radius-pill);
  stroke: currentColor; fill: none; stroke-width: 1.8;
}
.tab-item[aria-current="page"] {
  color: var(--brand);
  font-weight: 600;
}
.tab-item[aria-current="page"] .tab-icon {
  background: var(--brand-soft);
}

/* === 2. 页面头部（轻量无白框，直接落在画布底上） === */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) 0 var(--space-2);
}
.page-title {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.page-subtitle {
  margin: 2px 0 0;
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}
.page-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
.countdown-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: 600;
}

/* === 3. 题目卡（兼容行内/块级数学公式） === */
.quiz-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.quiz-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}
.quiz-stem {
  font-size: var(--text-md);
  line-height: 1.8;          /* 为分数、上下标留出垂直呼吸 */
  color: var(--text-primary);
  overflow-wrap: anywhere;
}
.quiz-formula-block {
  margin: var(--space-3) 0;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  overflow-x: auto;          /* 长公式独立横向滚动，不撑破手机屏 */
  -webkit-overflow-scrolling: touch;
  text-align: center;
}

/* === 4. 选项按钮（五种状态：颜色 + 边框线型 + 图标/文字三重区分） === */
.option-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.option-btn {
  width: 100%;
  min-height: 52px;          /* 高于 44px，单手大拇指容错高 */
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-default);
  background: var(--bg-surface);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  text-align: left;
  line-height: 1.65;
  transition: background-color 0.14s, border-color 0.14s, transform 0.1s;
}
.option-key {
  flex: none;
  width: 26px; height: 26px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-family: var(--font-num);
  font-size: var(--text-sm);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.option-body { flex: 1; min-width: 0; overflow-x: auto; }
.option-status {
  flex: none;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  align-self: center;
}

/* 状态 2：按下 */
.option-btn:active,
.option-btn.is-pressed {
  background: var(--brand-soft);
  border-color: var(--brand);
  transform: scale(0.99);
}
.option-btn:active .option-key,
.option-btn.is-pressed .option-key {
  background: var(--brand-solid);
  color: var(--text-inverse);
}

/* 状态 3：选中正确 */
.option-btn.is-correct {
  background: var(--ok-soft);
  border-color: var(--ok);
}
.option-btn.is-correct .option-key {
  background: var(--ok);
  color: var(--text-inverse);
}
.option-btn.is-correct .option-status {
  background: var(--ok);
  color: var(--text-inverse);
}
.option-btn.is-correct .option-status::before { content: "✓ "; }

/* 状态 4：选中错误 */
.option-btn.is-wrong {
  background: var(--err-soft);
  border-color: var(--err);
}
.option-btn.is-wrong .option-key {
  background: var(--err);
  color: var(--text-inverse);
}
.option-btn.is-wrong .option-status {
  background: var(--err);
  color: var(--text-inverse);
}
.option-btn.is-wrong .option-status::before { content: "✕ "; }

/* 状态 5：未选但为正确答案（虚线框 + 清晰文字标，与“选中正确”拉开层次） */
.option-btn.is-missed-answer {
  background: var(--bg-surface);
  border: 1.5px dashed var(--ok);
}
.option-btn.is-missed-answer .option-key {
  background: var(--ok-soft);
  color: var(--ok);
  border: 1px solid var(--ok-border);
}
.option-btn.is-missed-answer .option-status {
  background: var(--ok-soft);
  color: var(--ok);
  border: 1px solid var(--ok-border);
}
.option-btn.is-missed-answer .option-status::before { content: "✓ 正解"; }

/* === 5. 解析区（用下沉槽而非再套一张白卡） === */
.analysis-panel {
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.analysis-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-default);
  font-size: var(--text-sm);
  font-weight: 600;
}
.analysis-item {
  padding-left: var(--space-3);
  border-left: 3px solid var(--border-strong);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.7;
}
.analysis-item.is-correct { border-left-color: var(--ok); color: var(--text-primary); }
.analysis-item.is-wrong   { border-left-color: var(--err); }
.analysis-error-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px dashed var(--border-default);
}

/* === 6. 标签 / 小胶囊（可点型保底 44px，纯展示徽标紧凑） === */
.chip-group { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip-btn {
  min-height: var(--touch-min);
  padding: 0 var(--space-4);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.14s, border-color 0.14s;
}
.chip-btn[aria-pressed="true"],
.chip-btn.is-active {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
  font-weight: 600;
}
.chip-btn.is-err[aria-pressed="true"] {
  background: var(--err-soft);
  border-color: var(--err);
  color: var(--err);
}

/* 纯展示状态胶囊 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}
.badge--neutral { background: var(--bg-subtle); color: var(--text-secondary); }
.badge--ok      { background: var(--ok-soft);   color: var(--ok);   border: 1px solid var(--ok-border); }
.badge--warn    { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-border); }
.badge--err     { background: var(--err-soft);  color: var(--err);  border: 1px solid var(--err-border); }

/* === 7. 进度条（连续型 + 测评/章节分块型） === */
.progress-track {
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--brand);
  transition: width 0.35s ease;
}
.progress-fill--ok   { background: var(--ok); }
.progress-fill--warn { background: var(--warn); }
.progress-fill--err  { background: var(--err); }

.progress-segmented {
  display: flex;
  gap: 4px;
}
.progress-seg {
  flex: 1;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
}
.progress-seg.is-done    { background: var(--ok); }
.progress-seg.is-current { background: var(--brand); }

/* === 8. 知识点强弱行（图标+文字+进度条+“练这一类”按钮） === */
.kp-list {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.kp-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-subtle);
}
.kp-row:first-child { border-top: 0; }
.kp-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kp-head { display: flex; align-items: center; gap: var(--space-2); }
.kp-name {
  font-size: var(--text-base);
  font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* 强/中/弱：符号 + 文字 + 低饱和底色 */
.kp-level { font-size: var(--text-xs); font-weight: 600; padding: 2px 7px; border-radius: var(--radius-xs); flex: none; }
.kp-level.is-strong { background: var(--ok-soft);   color: var(--ok); }
.kp-level.is-strong::before { content: "● 强"; }
.kp-level.is-mid    { background: var(--warn-soft); color: var(--warn); }
.kp-level.is-mid::before    { content: "◐ 中"; }
.kp-level.is-weak   { background: var(--err-soft);  color: var(--err); }
.kp-level.is-weak::before   { content: "▲ 弱"; }

.kp-action {
  min-height: var(--touch-min);
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--brand-border);
  background: var(--brand-soft);
  color: var(--brand);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
}

/* === 9. 清单项（未完成 / 完成 / 顺延） === */
.todo-list {
  list-style: none;
  margin: 0; padding: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.todo-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 54px;
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-1);
  border-top: 1px solid var(--border-subtle);
}
.todo-item:first-child { border-top: 0; }

.todo-check {
  width: var(--touch-min);
  height: var(--touch-min);
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.todo-check-box {
  width: 22px; height: 22px;
  border-radius: 7px;
  border: 1.5px solid var(--border-strong);
  display: grid;
  place-items: center;
  transition: background-color 0.15s, border-color 0.15s;
}
.todo-content { flex: 1; min-width: 0; padding: var(--space-1) 0; }
.todo-title { font-size: var(--text-base); overflow-wrap: anywhere; }
.todo-meta { font-size: var(--text-xs); color: var(--text-tertiary); margin-top: 2px; }
.todo-defer-btn {
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}
.todo-defer-btn:hover { background: var(--bg-subtle); color: var(--text-primary); }

/* 完成态 */
.todo-item.is-done .todo-check-box {
  background: var(--ok);
  border-color: var(--ok);
  color: var(--text-inverse);
}
.todo-item.is-done .todo-check-box::after { content: "✓"; font-size: 13px; font-weight: 700; }
.todo-item.is-done .todo-title {
  color: var(--text-tertiary);
  text-decoration: line-through;
  text-decoration-color: var(--border-strong);
}

/* 顺延态（左侧虚线提示条 + 浅底 + “已顺延”标识） */
.todo-item.is-deferred {
  background: var(--bg-subtle);
  border-left: 3px dashed var(--warn);
}
.todo-item.is-deferred .todo-title { color: var(--text-secondary); }
.todo-item.is-deferred .todo-meta::before {
  content: "↷ 已顺延 · ";
  color: var(--warn);
  font-weight: 600;
}

/* === 10. 番茄钟圆环 === */
.pomo-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.pomo-ring-wrap {
  position: relative;
  width: 200px; height: 200px;
  display: grid;
  place-items: center;
}
.pomo-ring {
  width: 100%; height: 100%;
  transform: rotate(-90deg);
}
.pomo-track {
  fill: none;
  stroke: var(--bg-subtle);
  stroke-width: 10;
}
.pomo-progress {
  fill: none;
  stroke: var(--brand);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s linear, stroke 0.2s;
}
.pomo-progress.is-break { stroke: var(--ok); }
.pomo-center {
  position: absolute;
  text-align: center;
}
.pomo-time {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-kpi);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}
.pomo-phase { font-size: var(--text-xs); color: var(--text-tertiary); margin-top: 6px; }
.pomo-controls { display: flex; gap: var(--space-3); width: 100%; max-width: 280px; }
.pomo-btn {
  flex: 1;
  min-height: var(--touch-min);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-subtle);
  font-size: var(--text-sm);
  font-weight: 600;
}
.pomo-btn--primary {
  background: var(--brand-solid);
  border-color: transparent;
  color: var(--text-inverse);
}

/* === 11. 当天打分控件（1-5 档或百分分段，全热区 ≥44px） === */
.rating-control {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-2);
  padding: var(--space-1);
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
}
.rating-btn {
  min-height: var(--touch-min);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-secondary);
  font-size: var(--text-xs);
  border: 1px solid transparent;
  transition: background-color 0.14s, color 0.14s;
}
.rating-score {
  font-family: var(--font-num);
  font-size: var(--text-md);
  font-weight: 700;
  line-height: 1.1;
}
.rating-btn[aria-pressed="true"] {
  background: var(--bg-elevated);
  border-color: var(--accent-border);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* === 12. 统计数字块（平铺细线分隔带，避免 4 张碎白卡） === */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.kpi-cell {
  padding: var(--space-3) var(--space-2);
  text-align: center;
  border-left: 1px solid var(--border-subtle);
  min-width: 0;
}
.kpi-cell:first-child { border-left: 0; }
.kpi-value {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.15;
  color: var(--text-primary);
}
.kpi-value--accent { color: var(--accent); }
.kpi-value--ok     { color: var(--ok); }
.kpi-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* === 13. 教辅书章节题号打勾网格（每格 ≥44×44，多状态非纯色区分） === */
.exercise-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.exercise-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--touch-min), 1fr));
  gap: var(--space-2);
}
.exercise-cell {
  position: relative;
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-sm);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.12s, border-color 0.12s;
}
/* 已刷会 */
.exercise-cell.is-done {
  background: var(--ok-soft);
  border-color: var(--ok-border);
  color: var(--ok);
}
.exercise-cell.is-done::after {
  content: "✓";
  position: absolute;
  right: 4px; top: 2px;
  font-size: 10px;
  line-height: 1;
}
/* 错题/二刷（虚线框 + 底部色条 + 叉号） */
.exercise-cell.is-wrong {
  background: var(--err-soft);
  border: 1.5px dashed var(--err);
  color: var(--err);
}
.exercise-cell.is-wrong::after {
  content: "✕";
  position: absolute;
  right: 4px; top: 2px;
  font-size: 10px;
  line-height: 1;
}
/* 标记待回看 */
.exercise-cell.is-flagged {
  background: var(--warn-soft);
  border-color: var(--warn-border);
  color: var(--warn);
}
.exercise-cell.is-flagged::after {
  content: "★";
  position: absolute;
  right: 4px; top: 2px;
  font-size: 10px;
  line-height: 1;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* 移动端默认单栏 */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.app-main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 var(--space-4) calc(var(--nav-h) + var(--safe-bottom) + var(--space-6));
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.layout-today,
.layout-quiz,
.layout-progress {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* === 宽屏 ≥900px：左侧栏 + 两栏主区 === */
@media (min-width: 900px) {
  .app-shell {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
  }

  /* 底部标签栏 → 左侧固定导航 */
  .tab-bar {
    position: sticky;
    top: 0;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-1);
    padding: var(--space-5) var(--space-3);
    box-shadow: none;
    border-right: 1px solid var(--border-subtle);
  }
  .tab-item {
    min-height: 44px;
    flex-direction: row;
    justify-content: flex-start;
    gap: var(--space-3);
    padding: 0 var(--space-3);
    font-size: var(--text-base);
  }
  .tab-icon { padding: 0; background: none !important; }
  .tab-item[aria-current="page"] { background: var(--brand-soft); }

  /* 右侧主区域放宽到 1160px，不再缩成窄条 */
  .app-main {
    max-width: var(--container-max);
    padding: var(--space-6) var(--space-8) var(--space-8);
    gap: var(--space-5);
  }

  /* 1) 「今天」两栏：左侧目标清单 + 打分；右侧吸顶番茄钟 + 倒计时/连续打卡 */
  .layout-today {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, 360px);
    gap: var(--space-6);
    align-items: start;
  }
  .layout-today-side {
    position: sticky;
    top: var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
  }

  /* 2) 「刷题」自适应：未作答时居中专注阅读；作答后左右分栏（左题右解，不反复翻滚） */
  .layout-quiz {
    max-width: 740px;
    width: 100%;
    margin: 0 auto;
  }
  .layout-quiz.has-analysis {
    max-width: none;
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    gap: var(--space-5);
    align-items: start;
  }
  .layout-quiz.has-analysis .analysis-panel {
    position: sticky;
    top: var(--space-6);
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
  }

  /* 3) 「测评 / 进度」两栏：总进度与统计条横跨全宽，下方薄弱点与统计错题并排 */
  .layout-progress {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: var(--space-5);
    align-items: start;
  }
  .layout-span-full { grid-column: 1 / -1; }
}

/* === 超宽屏 ≥1240px：「进度」升级为三栏（薄弱点 | 错因与常错 | 教辅打勾格） === */
@media (min-width: 1240px) {
  .layout-progress--three {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.95fr) minmax(300px, 1fr);
  }
  .exercise-grid {
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  }
}

/* ===== 应用专用样式（接在 design.base.css 之后） ===== */
[hidden] { display: none !important; }
h2 { margin: 0; font-size: var(--text-lg); font-weight: 700; }
p { margin: 0; }
.hint { color: var(--text-tertiary); font-size: var(--text-sm); }
.txt-ok { color: var(--ok); } .txt-err { color: var(--err); }
.stack { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }
.app-main { padding-top: env(safe-area-inset-top, 0px); }
.app-main > * { min-width: 0; }
.katex { font-size: 1.08em; }
.katex-display { margin: 0; }

/* 导航 */
.tab-bar { grid-template-columns: repeat(var(--tabs, 4), 1fr); }
.brand { display: none; }
.icon-btn { width: var(--touch-min); height: var(--touch-min); display: inline-grid; place-items: center; border-radius: var(--radius-sm); color: var(--text-secondary); }
.icon-btn .tab-icon { padding: 0; }
.icon-btn:hover { background: var(--bg-subtle); }
.status-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); min-height: 20px; margin-top: calc(var(--space-2) * -1); }
.sync-pill { font-size: var(--text-xs); color: var(--text-tertiary); }
.sync-pill[data-s="ok"]::before { content: "● "; color: var(--ok); }
.sync-pill[data-s="offline"]::before, .sync-pill[data-s="badkey"]::before { content: "▲ "; color: var(--warn); }
.sync-pill[data-s="local"]::before { content: "○ "; }
.link-btn { color: var(--brand); font-size: var(--text-sm); text-decoration: underline; min-height: 32px; }

/* 通用块 */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-3); }
.row-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.btn { min-height: var(--touch-min); padding: 0 var(--space-4); border-radius: var(--radius-sm); font-size: var(--text-base); font-weight: 600; flex: 1 1 auto; }
.btn--primary { background: var(--brand-solid); color: var(--text-inverse); }
.btn--ghost { border: 1px solid var(--border-default); background: var(--bg-surface); color: var(--text-primary); }
.btn--danger { border: 1px solid var(--err-border); background: var(--err-soft); color: var(--err); }
.btn:disabled, .option-btn:disabled { cursor: default; }
.btn:disabled { opacity: .45; }
.option-btn:disabled { color: var(--text-primary); }
.empty { padding: var(--space-8) var(--space-4); text-align: center; background: var(--bg-subtle); border-radius: var(--radius-md); display: flex; flex-direction: column; gap: var(--space-2); }
.progress-track--lg { height: 10px; }

/* 今天 */
.todo-title { line-height: 1.5; }
.week-list { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4); background: var(--bg-subtle); border-radius: var(--radius-md); }
.week-date { font-weight: 600; font-size: var(--text-sm); }
.week-day ul { margin: 4px 0 0; padding-left: 1.2em; color: var(--text-secondary); font-size: var(--text-sm); }
.kpi-of { font-size: var(--text-base); color: var(--text-tertiary); font-weight: 500; }
.layout-today-side { display: flex; flex-direction: column; gap: var(--space-4); }

/* 刷题 */
.chip-n { color: var(--text-tertiary); font-weight: 400; }
.chip-group--scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin-right: calc(var(--space-4) * -1); padding-right: var(--space-4); }
.chip-group--scroll::-webkit-scrollbar { display: none; }
.chip-group--scroll .chip-btn { flex: none; }
.chip-btn { min-height: 40px; padding: 0 var(--space-3); }
.analysis-error-bar { align-items: center; }
.analysis-exp { font-size: var(--text-base); line-height: 1.85; overflow-wrap: anywhere; }
.analysis-exp .katex-display, .quiz-formula-block { overflow-x: auto; overflow-y: hidden; }
.analysis-label { font-size: var(--text-xs); font-weight: 700; color: var(--text-tertiary); letter-spacing: .08em; margin-bottom: 2px; }
.analysis-item { overflow-x: auto; overflow-y: hidden; }
.option-btn--plain { border-style: dashed; color: var(--text-secondary); }
.option-body { overflow-y: hidden; }

/* 测评 */
.assess-list { display: flex; flex-direction: column; background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); overflow: hidden; }
.assess-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border-subtle); flex-wrap: wrap; }
.assess-row:first-child { border-top: 0; }
.assess-name { font-weight: 600; }
.assess-btns { display: flex; gap: var(--space-2); }
.kp-score { font-weight: 700; color: var(--text-secondary); }
.fold { border-top: 1px solid var(--border-default); padding: var(--space-3) 0; }
.fold > summary { cursor: pointer; font-weight: 600; min-height: 32px; line-height: 1.8; overflow-x: auto; overflow-y: hidden; }
.fold[open] > summary { margin-bottom: var(--space-3); }
.fold > *:not(summary) { margin-top: var(--space-2); }
.fold-kp { font-size: var(--text-xs); color: var(--text-tertiary); font-weight: 500; margin-right: 8px; }

/* 进度 */
.bars { display: flex; flex-direction: column; gap: var(--space-2); }
.bar-row { display: grid; grid-template-columns: 5.5em 1fr 2em; align-items: center; gap: var(--space-2); font-size: var(--text-sm); }
.q-list { display: flex; flex-direction: column; }
.q-row { display: flex; gap: var(--space-3); align-items: flex-start; text-align: left; padding: var(--space-3) 0; border-top: 1px solid var(--border-subtle); min-height: var(--touch-min); width: 100%; }
.q-row:first-child { border-top: 0; }
.q-mark { flex: none; min-width: 2.2em; font-weight: 700; text-align: center; }
.q-text { flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden; font-size: var(--text-sm); line-height: 1.8; }
.q-kp { display: block; }

/* 表单 */
.field { display: flex; flex-direction: column; gap: 4px; }
.field--inline { flex-direction: row; align-items: center; gap: var(--space-2); min-height: var(--touch-min); }
input:not([type="checkbox"]), select, textarea { width: 100%; min-height: var(--touch-min); padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-default); background: var(--bg-surface); font-size: 16px; }
textarea { line-height: 1.5; resize: vertical; font-family: var(--font-mono); font-size: 14px; }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--brand); }
.edit-row { display: grid; grid-template-columns: 5.5em 1fr var(--touch-min); gap: var(--space-2); align-items: center; }

/* 弹层与提示 */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-scrim { position: absolute; inset: 0; background: var(--bg-scrim); }
.sheet-body { position: relative; width: 100%; max-width: 720px; max-height: 88dvh; overflow-y: auto; background: var(--bg-canvas); border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: var(--space-5) var(--space-4) calc(var(--space-5) + var(--safe-bottom)); display: flex; flex-direction: column; gap: var(--space-3); box-shadow: var(--shadow-md); }
.sheet-close { flex: none; margin-top: var(--space-2); }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-bottom) + 20px); transform: translateX(-50%); z-index: 60; max-width: min(92vw, 420px); padding: 10px 16px; border-radius: var(--radius-pill); background: var(--text-primary); color: var(--bg-canvas); font-size: var(--text-sm); box-shadow: var(--shadow-md); text-align: center; }
.tw { overflow-x: auto; }
.tbl { border-collapse: collapse; font-size: var(--text-sm); width: 100%; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-top: 1px solid var(--border-subtle); white-space: nowrap; }
.tbl thead th { border-top: 0; color: var(--text-secondary); font-weight: 600; }

@media (min-width: 900px) {
  .brand { display: block; font-size: var(--text-lg); font-weight: 700; padding: 0 var(--space-3) var(--space-4); letter-spacing: .02em; }
  .tab-bar { background: var(--bg-canvas); }
  .sheet { align-items: center; }
  .sheet-body { border-radius: var(--radius-lg); }
  .toast { bottom: 32px; }
  .layout-quiz.has-analysis .analysis-panel { align-self: start; }
  .chip-group--scroll { flex-wrap: wrap; overflow: visible; margin-right: 0; padding-right: 0; }
}

.page-header .btn { flex: none; white-space: nowrap; }
.page-header > div:first-child { min-width: 0; }
.countdown-pill { white-space: nowrap; }

.kpi-strip--4 { grid-template-columns: repeat(2, 1fr); }
.kpi-strip--4 .kpi-cell:nth-child(odd) { border-left: 0; }
.kpi-strip--4 .kpi-cell:nth-child(n+3) { border-top: 1px solid var(--border-subtle); }
@media (min-width: 560px) { .kpi-strip--4 { grid-template-columns: repeat(4, 1fr); } .kpi-strip--4 .kpi-cell:nth-child(odd) { border-left: 1px solid var(--border-subtle); } .kpi-strip--4 .kpi-cell:first-child { border-left: 0; } .kpi-strip--4 .kpi-cell:nth-child(n+3) { border-top: 0; } }
