/* 小学闯关 · 练习本主题
   设计约束：
   - 色彩只做两件事：靛蓝=可交互，朱红=批改（星星/错误）。其余用墨色层级。
   - 中文不引 webfont（几 MB，线上是 2C2G 国内服务器），靠字重/字号/字距建立层级。
   - 数字一律 tabular-nums，星数、进度、题号才能竖直对齐。 */

:root {
  --paper: #faf9f4;
  --surface: #ffffff;
  --ink: #1f262b;
  --ink-2: #4b555e;
  --muted: #78828a;
  --line: #e3e1d7;
  --line-strong: #cfccc0;
  --accent: #1f5fcf;
  --accent-soft: #e9eef9;
  --grid: #edeadf;
  --mark: #b23a48;
  --ok: #1f6f5c;
  --bad: #a63a4a;
  --ok-bg: #e9f4ee;
  --bad-bg: #f9e9e8;
  --note: #fbf3d5;
  --chinese: #a63a4a;
  --math: #1f6f5c;
  --english: #1f5fcf;
  --subject: var(--accent);
  --shadow: 0 1px 2px rgba(31, 38, 43, 0.05), 0 10px 26px rgba(31, 38, 43, 0.06);
  --radius: 8px;
}

/* 护眼：暖绿纸，仍保持同一套层级 */
body[data-theme="eye"] {
  --paper: #eef1e6;
  --surface: #f8f8ef;
  --ink: #232a22;
  --ink-2: #4a5446;
  --muted: #6f7a66;
  --line: #dcdcc9;
  --line-strong: #c7c6ae;
  --accent: #2c6a52;
  --accent-soft: #dfe9d6;
  --grid: #e3e4d2;
  --mark: #9c3b3b;
  --ok: #2c6a45;
  --bad: #97393a;
  --ok-bg: #e3efdd;
  --bad-bg: #f2e3dc;
  --note: #f4eccb;
  --chinese: #9c3b3b;
  --math: #2c6a52;
  --english: #2f5f9e;
}

body[data-theme="dark"] {
  --paper: #14181b;
  --surface: #1a1f23;
  --ink: #e9e6de;
  --ink-2: #bcb9b0;
  --muted: #8c939a;
  --line: #2a3036;
  --line-strong: #3b434b;
  --accent: #7ea6ff;
  --accent-soft: #1d2a3d;
  --grid: #1b2126;
  --mark: #e08680;
  --ok: #6fd3a8;
  --bad: #f09b95;
  --ok-bg: #16302a;
  --bad-bg: #35201f;
  --note: #2a2418;
  --chinese: #e08a95;
  --math: #5ec3a4;
  --english: #7ea6ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* 跟随系统（未显式选主题时） */
@media (prefers-color-scheme: dark) {
  body:not([data-theme]) {
    --paper: #14181b;
    --surface: #1a1f23;
    --ink: #e9e6de;
    --ink-2: #bcb9b0;
    --muted: #8c939a;
    --line: #2a3036;
    --line-strong: #3b434b;
    --accent: #7ea6ff;
    --accent-soft: #1d2a3d;
    --grid: #1b2126;
    --mark: #e08680;
    --ok: #6fd3a8;
    --bad: #f09b95;
    --ok-bg: #16302a;
    --bad-bg: #35201f;
    --note: #2a2418;
    --chinese: #e08a95;
    --math: #5ec3a4;
    --english: #7ea6ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 40px 40px;
}
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- 顶栏 ---------- */
.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.masthead-in {
  max-width: 1160px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-mark {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  border-radius: 7px; font-size: 15px; font-weight: 700;
}
.brand-name { display: block; font-size: 19px; font-weight: 700; letter-spacing: .01em; line-height: 1.2; }
.brand-sub { display: block; font-size: 11px; color: var(--muted); letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.hud { margin-left: auto; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.stat { display: inline-flex; align-items: baseline; gap: 5px; padding: 4px 8px; font-variant-numeric: tabular-nums; }
.stat-key { font-size: 12px; color: var(--mark); }
.stat-coin .stat-key { color: var(--muted); }
.stat-val { font-weight: 600; font-size: 14px; }
.hud-div { width: 1px; height: 18px; background: var(--line); margin: 0 6px; }
.hud-btn {
  border: 1px solid transparent; background: transparent; color: var(--ink-2);
  font-size: 13px; padding: 6px 10px; border-radius: 6px; cursor: pointer;
}
.hud-btn:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }
a.hud-btn { text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.hud-count {
  margin-left: 6px; font-size: 11px; line-height: 1.6; padding: 0 6px;
  border-radius: 999px; background: var(--mark); color: #fff; font-variant-numeric: tabular-nums;
}

/* ---------- 布局 ---------- */
.layout {
  max-width: 1160px; margin: 0 auto; padding: 28px 24px 40px;
  display: grid; grid-template-columns: 208px minmax(0, 1fr); gap: 40px; align-items: start;
}
.rail { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 24px; }
.rail-h { margin: 0 0 8px; font-size: 11px; font-weight: 600; letter-spacing: .14em; color: var(--muted); }

/* 答题 / 错题本时收起侧栏，专注当前任务 */
body[data-view="play"] .rail,
body[data-view="wrong"] .rail { display: none; }
body[data-view="play"] .layout,
body[data-view="wrong"] .layout { grid-template-columns: minmax(0, 1fr); max-width: 900px; }

.grade-list, .subject-list { display: flex; flex-direction: column; gap: 2px; }
.grade-btn, .subject-btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 10px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--ink-2); text-align: left; cursor: pointer;
}
.grade-btn:hover, .subject-btn:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }
.grade-btn.active, .subject-btn.active {
  background: var(--surface); border-color: var(--line-strong); color: var(--ink);
  font-weight: 600; box-shadow: inset 2px 0 0 var(--accent);
}
.grade-btn:disabled { color: var(--muted); opacity: .55; cursor: not-allowed; text-decoration: line-through; }
.grade-label, .subject-label { flex: 1; }
.grade-count, .subject-count { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--accent); }

.term-row { display: flex; gap: 4px; }
.term-btn {
  flex: 1; padding: 5px 0; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--ink-2); font-size: 12px; cursor: pointer;
}
.term-btn:hover { border-color: var(--line-strong); color: var(--ink); }
.term-btn.active { border-color: var(--accent); color: var(--accent); font-weight: 600; background: var(--accent-soft); }

.rail-progress { border-top: 1px solid var(--line); padding-top: 16px; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 6px; background: var(--accent); border-radius: 3px; }
.rail-note { margin: 8px 0 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- 主区 ---------- */
.app { min-width: 0; }
.crumbs { color: var(--muted); }

.resume {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "kicker go" "title go" "meta go"; gap: 2px 18px;
  align-items: center; width: 100%; text-align: left;
  margin: 0 0 30px; padding: 14px 18px;
  background: var(--surface); border: 1px solid var(--line-strong); border-left: 3px solid var(--accent);
  border-radius: var(--radius); box-shadow: var(--shadow);
  color: inherit; cursor: pointer;
}
.resume-kicker { grid-area: kicker; font-size: 11px; font-weight: 600; letter-spacing: .14em; color: var(--accent); }
.resume-title { grid-area: title; font-size: 17px; font-weight: 600; letter-spacing: .01em; }
.resume-meta { grid-area: meta; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.resume-go { grid-area: go; align-self: center; font-size: 14px; font-weight: 600; color: var(--accent); white-space: nowrap; }
.resume:hover { border-color: var(--accent); }

/* ---------- 模块与关卡 ---------- */
.module { margin-bottom: 34px; }
.module-head {
  display: flex; align-items: baseline; gap: 10px;
  padding-bottom: 8px; margin-bottom: 14px; border-bottom: 1px solid var(--line-strong);
}
.module-head h2 {
  margin: 0; font-size: 17px; font-weight: 700; letter-spacing: .02em;
  display: flex; align-items: center; gap: 9px;
}
.module-head h2::before {
  content: ""; width: 4px; height: 15px; border-radius: 2px; background: var(--subject);
}
.module-meta { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.kp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(288px, 1fr)); gap: 14px; }
.kp-card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.kp-card.locked { opacity: .72; }
.kp-lock-note { margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.kp-head { display: flex; align-items: baseline; gap: 8px; padding: 11px 14px 9px; }
.kp-head h3 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: .01em; text-wrap: balance; }
.kp-meta { margin-left: auto; font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.kp-meta.done { color: var(--accent); font-weight: 600; }

.levels { list-style: none; margin: 0; padding: 0; }
.level {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 14px; border: 0; border-top: 1px solid var(--line);
  background: transparent; color: var(--ink); font-size: 14px; text-align: left; cursor: pointer;
}
.level:hover:not(:disabled) { background: var(--accent-soft); }
.level:disabled { color: var(--muted); cursor: default; }
.level-name { flex: 1; min-width: 0; }
.stars { font-size: 13px; letter-spacing: 2px; color: var(--mark); white-space: nowrap; font-variant-numeric: tabular-nums; }
.stars .off { color: var(--line-strong); }
.lock-mark { font-size: 11px; color: var(--muted); white-space: nowrap; }
.practice-tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 999px; padding: 0 8px; white-space: nowrap; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  padding: 8px 15px; border-radius: 6px; font-size: 14px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }

/* ---------- 答题 ---------- */
.play-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--line-strong);
}
.play-title { font-weight: 600; font-size: 16px; }
.progress { margin-left: auto; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.stage { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px; }
.question .q-stem { font-size: 18px; font-weight: 600; margin: 6px 0 14px; line-height: 1.65; }
.parent-stem { color: var(--muted); margin: 0 0 6px; }
.passage {
  background: var(--accent-soft); border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: 0 6px 6px 0; margin: 0 0 12px; white-space: pre-wrap;
}
.q-audio { margin: 8px 0; }
.q-img { max-width: 100%; border-radius: 6px; }
.q-body { display: flex; flex-direction: column; gap: 9px; }

.option {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 11px 14px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--surface); color: var(--ink); font-size: 16px; cursor: pointer;
}
.option:hover { border-color: var(--line-strong); background: var(--accent-soft); }
.option.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.opt-img { height: 40px; border-radius: 5px; }

.blank-input, .match-select, .chat-input {
  font-size: 16px; padding: 8px 10px;
  border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--surface); color: var(--ink);
}
.blank-input { width: 130px; margin: 0 4px; }
.fill-line { font-size: 17px; line-height: 2.4; }
.match-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.match-left { min-width: 90px; font-weight: 600; }
.order-tray, .order-pool {
  display: flex; flex-wrap: wrap; gap: 8px; min-height: 44px; padding: 8px;
  border: 1px dashed var(--line-strong); border-radius: 8px;
}
.order-pool { border-style: solid; }
.chip {
  background: var(--accent-soft); border: 1px solid var(--accent); color: var(--accent);
  border-radius: 999px; padding: 7px 13px; font-size: 15px; cursor: pointer;
}
.chip.ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.target { font-size: 17px; background: var(--note); border-radius: 6px; padding: 12px; margin: 0 0 10px; }
.transcript:not(:empty) { font-size: 14px; background: var(--accent-soft); border-radius: 6px; padding: 8px 10px; }
.hint { color: var(--muted); font-size: 13px; }

.play-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.feedback { margin-top: 14px; border-radius: 8px; padding: 0; }
.feedback.ok, .feedback.bad { padding: 12px 14px; }
.feedback.ok { background: var(--ok-bg); color: var(--ok); }
.feedback.bad { background: var(--bad-bg); color: var(--bad); }
.feedback p { margin: 8px 0 0; color: var(--ink-2); }

/* ---------- 结算 ---------- */
.result {
  text-align: center; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 30px;
}
.result h2 { margin: 0 0 6px; font-size: 22px; }
.big-stars { font-size: 40px; color: var(--mark); letter-spacing: 6px; }

/* ---------- 低龄模式（一、二年级）---------- */
body[data-lowage="1"] .kp-head h3 { font-size: 17px; }
body[data-lowage="1"] .level { padding: 12px 16px; font-size: 17px; }
body[data-lowage="1"] .q-stem { font-size: 21px; line-height: 1.75; }
body[data-lowage="1"] .parent-stem { font-size: 18px; }
body[data-lowage="1"] .passage { font-size: 19px; line-height: 1.9; }
body[data-lowage="1"] .option { padding: 14px 16px; font-size: 19px; border-radius: 9px; }
body[data-lowage="1"] .btn { padding: 11px 20px; font-size: 16px; }
body[data-lowage="1"] .blank-input { font-size: 19px; padding: 8px 12px; }
body[data-lowage="1"] .match-select { font-size: 17px; padding: 10px 12px; }
body[data-lowage="1"] .chip { font-size: 18px; padding: 9px 15px; }

/* ---------- 错题本 ---------- */
.wbook { display: flex; flex-direction: column; gap: 14px; }
.wbook-tree { display: flex; flex-direction: column; gap: 2px; margin: 6px 0 4px; }
.wtree-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 1px solid transparent; background: transparent; color: var(--ink);
  border-radius: 6px; padding: 7px 10px; font-size: 14px; cursor: pointer; text-align: left;
}
.wtree-row:hover { background: var(--surface); border-color: var(--line); }
.wtree-row.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.wtree-row.active .wtree-count { background: var(--surface); color: var(--accent); }
.wtree-label { flex: 1; }
.wtree-count { flex: none; font-size: 12px; color: var(--muted); background: var(--surface); border-radius: 999px; padding: 1px 9px; font-variant-numeric: tabular-nums; }
.wtree-grade { font-weight: 600; padding-left: 6px; }
.wtree-caret { flex: none; border: none; background: transparent; color: var(--muted); font-size: 12px; width: 16px; padding: 0; cursor: pointer; }
.wtree-main { flex: 1; display: flex; align-items: center; gap: 8px; border: none; background: transparent; color: inherit; font: inherit; cursor: pointer; padding: 0; text-align: left; }
.wtree-sub { margin-left: 22px; font-weight: 400; }
.wpager { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 10px 0 4px; color: var(--muted); font-size: 13px; }
.wpager-size { padding: 5px 9px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--ink); }
.wcheck { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.wcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.wcard-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin-bottom: 6px; font-size: 15px; }
.wopts { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.wopt { padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); font-size: 14px; }
.wopt.correct { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.wans { margin-top: 8px; font-weight: 600; }
.wexp { margin-top: 6px; color: var(--muted); }
.wlabel { color: var(--accent); font-weight: 700; margin-right: 4px; }
.wcard-foot { margin-top: 10px; }

/* ---------- AI 面板 ---------- */
.ai-panel {
  position: fixed; right: 16px; bottom: 16px;
  width: min(380px, calc(100vw - 32px)); max-height: 70vh;
  display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: var(--shadow); z-index: 30; overflow: hidden;
}
.ai-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.ai-head strong { font-size: 14px; }
.chat-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; min-height: 150px; }
.msg { padding: 8px 12px; border-radius: 10px; max-width: 85%; white-space: pre-wrap; line-height: 1.55; font-size: 14px; }
.msg.user { align-self: flex-end; background: var(--accent-soft); }
.msg.ai { align-self: flex-start; background: var(--paper); border: 1px solid var(--line); }
.msg.error { background: var(--bad-bg); color: var(--bad); }
.bubble-tools { display: flex; gap: 6px; margin-top: 6px; }
.speak-btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 999px; padding: 2px 10px; font-size: 12px; cursor: pointer; }
.speak-btn:hover { border-color: var(--accent); color: var(--accent); }
.ipa { display: inline-block; color: var(--muted); font-family: ui-monospace, SFMono-Regular, monospace; font-size: 12px; margin-right: 6px; }
.chat-bar { display: flex; gap: 8px; padding: 8px 12px; }
.chat-input { flex: 1; border-radius: 999px; padding: 8px 14px; }
.chat-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ai-panel .hint { padding: 0 12px 10px; margin: 0; }
.tts-settings { padding: 8px 12px; font-size: 12px; border-top: 1px solid var(--line); }
.tts-settings summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.tts-settings label { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.tts-settings select { flex: 1; min-width: 0; font-size: 12px; accent-color: var(--accent); }
.tts-settings input[type="range"] { flex: 1; accent-color: var(--accent); }
.tts-settings .btn { margin-top: 6px; }

/* ---------- 今日目标 ---------- */
.rail-note.done { color: var(--ok); font-weight: 600; }

/* ---------- 提示卡 ---------- */
.option.hint-removed { opacity: .45; text-decoration: line-through; }

/* ---------- 我的形象 ---------- */
.avatar-box {
  width: 100%; aspect-ratio: 1 / 1; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
}
.avatar-box svg { display: block; width: 100%; height: 100%; }
#btn-avatar { width: 100%; margin-top: 8px; }

/* ---------- 小卖部 ---------- */
.shop-balance { margin: 0; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.shop-balance b { color: var(--ink); font-size: 16px; }
.shop-sep { margin: 0 8px; }
.shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.shop-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.shop-tabs .chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.shop-tabs .chip.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.shop-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 8px 0 12px; }
.shop-list .shop-item { display: flex; flex-direction: column; gap: 6px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.shop-list .avatar-premium { grid-column: 1 / -1; align-items: center; text-align: center; }
.shop-actions { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.item-preview {
  height: 136px; margin-bottom: 4px; display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
.item-preview svg { width: 100%; height: 100%; }
.item-preview .item-img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; padding: 4px; box-sizing: border-box; }
.recycle-card .shop-actions { margin-top: 6px; }
.recycle-card > .btn { margin-top: 6px; align-self: flex-start; }
.stepper { display: flex; align-items: center; gap: 10px; margin: 4px 0; }
.stepper .btn { width: 34px; padding: 4px 0; font-size: 16px; line-height: 1; }
.stepper-val { min-width: 28px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.hint-wallet .item-preview { height: 120px; }
.recycle-card.is-empty { opacity: .6; }

.qty-input {
  width: 72px; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--surface); color: var(--ink); font: inherit; text-align: center;
}
.shop-actions .btn { flex: 1; padding: 6px 8px; font-size: 13px; }
.avatar-preview { width: 168px; height: 168px; margin: 0 auto 4px; }
.avatar-preview svg { width: 100%; height: 100%; display: block; }
.shop-item {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper);
}
.shop-item strong { font-size: 15px; }
.shop-item .hint { margin: 0; }
.shop-item .btn { margin-top: 8px; align-self: start; }

/* ---------- 反馈动效（prefers-reduced-motion 时全局关闭） ---------- */
@keyframes pop-in {
  0% { transform: scale(.7); opacity: .3; }
  60% { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.feedback.ok strong { display: inline-block; animation: pop-in .28s ease-out; }
.big-stars { animation: pop-in .5s ease-out; }

/* 轻提示 */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-left: 3px solid var(--mark);
  border-radius: 8px; padding: 10px 14px; box-shadow: var(--shadow);
  font-size: 14px; z-index: 40;
}

/* ---------- 弹窗 ---------- */
.dialog {
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 20px;
  max-height: 86vh; overflow-y: auto;
  width: min(560px, 92vw); background: var(--surface); color: var(--ink);
  box-shadow: 0 20px 50px rgba(20, 24, 27, 0.25);
}
.dialog::backdrop { background: rgba(20, 24, 27, 0.35); }
.dialog h3 { margin-top: 0; }
.dialog textarea {
  width: 100%; font-family: ui-monospace, monospace; font-size: 12px;
  border: 1px solid var(--line-strong); border-radius: 6px; padding: 10px;
  background: var(--paper); color: var(--ink);
}
.dialog menu { display: flex; gap: 10px; padding: 0; margin: 14px 0 0; }

/* ---------- 入口：选人 / 建档 ---------- */
body.gated { overflow: hidden; }

.gate {
  position: fixed; inset: 0; z-index: 90; overflow-y: auto;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background:
    radial-gradient(120% 80% at 50% -10%, var(--accent-soft) 0%, transparent 62%),
    var(--paper);
}
.gate-card {
  width: min(720px, 100%); background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 18px; padding: 30px 30px 24px;
  box-shadow: 0 24px 60px rgba(31, 38, 43, 0.14);
}
.gate-title { margin: 0 0 6px; font-size: 28px; letter-spacing: 0.02em; }
.gate-sub { margin: 0 0 20px; color: var(--ink-2); font-size: 14px; }
.gate-empty { grid-column: 1 / -1; color: var(--muted); font-size: 14px; margin: 0 0 4px; }
.gate-form-h { margin: 22px 0 10px; font-size: 15px; color: var(--ink-2); font-weight: 600; }
.gate-err { min-height: 20px; margin: 8px 0 0; font-size: 13px; color: var(--bad); }

.student-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; }
.student-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 16px 10px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--paper); color: var(--ink); cursor: pointer; font: inherit;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}
.student-cell { position: relative; display: flex; }
.student-cell .student-card { flex: 1; }
.student-del {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px;
  display: grid; place-items: center; border-radius: 50%;
  border: 1px solid transparent; background: transparent; color: var(--muted);
  font-size: 13px; line-height: 1; cursor: pointer; opacity: 0.38; transition: opacity 0.12s, background 0.12s, color 0.12s;
}
.student-cell:hover .student-del, .student-del:focus-visible { opacity: 1; }
.student-del:hover { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.student-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 8px 20px rgba(31, 38, 43, 0.1); }
.student-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.student-card.current { border-color: var(--accent); background: var(--accent-soft); }
.student-av {
  width: 64px; height: 64px; border-radius: 50%; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  display: grid; place-items: center; margin-bottom: 4px;
}
.student-av svg { width: 100%; height: 100%; }
.student-name { font-weight: 600; font-size: 15px; }
.student-meta { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.student-form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.text-input {
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 9px 11px;
}
.text-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.student-form-row .text-input:first-child { flex: 1 1 160px; min-width: 0; }
.student-form-row select.text-input { flex: 0 0 auto; }

/* 顶栏里的「当前同学」 */
.profile-btn { display: inline-flex; align-items: center; gap: 7px; padding-left: 6px; }
.profile-av {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent);
}
.profile-name { max-width: 7em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-caret { font-size: 9px; opacity: 0.55; }

/* ---------- 旋转题 ---------- */
.rotate-stage {
  position: relative; width: min(300px, 76vw); aspect-ratio: 1;
  margin: 4px auto 6px; border-radius: 50%; touch-action: none;
  cursor: grab; outline: none;
}
.rotate-stage:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); }
.rotate-stage.dragging { cursor: grabbing; }
.rotate-stage.locked { cursor: default; }
.rotate-svg { display: block; width: 100%; height: 100%; }
.rotate-dial { fill: var(--surface); stroke: var(--line); stroke-width: 2; }
.rotate-tick { stroke: var(--line-strong); stroke-width: 2; stroke-linecap: round; }
.rotate-notch { fill: var(--mark); }
.rotate-ghost { color: var(--muted); }
.rotate-ghost * { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-dasharray: 7 7; opacity: .55; }
.rotate-active { color: var(--accent); transition: color .16s ease; }
.rotate-stage.near .rotate-active { color: var(--ok); }
.rotate-hint { text-align: center; }

/* ---------- 每日任务 ---------- */
.task-list { display: flex; flex-direction: column; gap: 10px; margin: 10px 0 4px; }
.task-item {
  border: 1px solid var(--line); border-radius: 10px; background: var(--paper);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 8px;
}
.task-item.done { border-color: var(--accent); background: var(--accent-soft); }
.task-item.claimed { opacity: 0.6; }
.task-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.task-top strong { font-size: 14px; }
.task-reward { font-size: 12px; color: var(--mark); white-space: nowrap; }
.task-bottom { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.task-bottom .btn { padding: 4px 14px; }
.task-bonus { font-size: 13px; color: var(--ink-2); margin: 12px 0 0; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 26px; padding-top: 20px; }
  .rail { position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px; }
  .rail-progress { grid-column: 1 / -1; }
  .grade-list, .subject-list { flex-direction: row; flex-wrap: wrap; }
  .grade-btn, .subject-btn { width: auto; padding: 6px 10px; }
  .grade-count, .subject-count { display: none; }
  .grade-btn.active, .subject-btn.active { box-shadow: inset 0 -2px 0 var(--accent); }
}
@media (max-width: 600px) {
  .masthead-in { padding: 10px 16px; gap: 10px; }
  .brand-sub { display: none; }
  .hud { gap: 0; }
  .hud-btn { padding: 6px 8px; }
  .layout { padding: 18px 16px 32px; }
  .rail { grid-template-columns: 1fr; }
  .kp-grid { grid-template-columns: 1fr; }
  .resume { grid-template-columns: 1fr; grid-template-areas: "kicker" "title" "meta" "go"; }
  .resume-go { justify-self: start; }
  .stage { padding: 14px; }
  .play-head { gap: 8px; }
  .ai-panel { right: 8px; bottom: 8px; width: calc(100vw - 16px); }
  .shop-grid { grid-template-columns: 1fr; }
  .shop-list { grid-template-columns: 1fr; }
}
