:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #1f2430;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --brand: #4f46e5;
  --brand-soft: #eef2ff;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --green: #16a34a;
  --green-soft: #f0fdf4;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 16px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* 修复：display:flex/grid 会覆盖 hidden 属性，这里强制 hidden 生效 */
[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== 顶栏 ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: 56px;
}
.brand { font-size: 18px; font-weight: 700; color: var(--brand); letter-spacing: -0.3px; }
.brand span { font-weight: 500; color: var(--text-2); font-size: 15px; }
.tabs { display: flex; gap: 4px; }
.topbar-right { display: flex; align-items: center; gap: 16px; margin-left: auto; }
.tab {
  border: none;
  background: transparent;
  padding: 8px 16px;
  font-size: 14px;
  color: var(--text-2);
  border-radius: 10px;
  cursor: pointer;
  transition: all .15s;
}
.tab:hover { background: #f3f4f6; color: var(--text); }
.tab.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

/* 顶栏用户区 */
.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-user[hidden] { display: none; }
.tu-phone { font-size: 13px; color: var(--text-2); }
.tu-logout {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
}
.tu-logout:hover { color: var(--red); border-color: #fca5a5; }

/* 登录：验证码行 */
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; }
.code-row .btn { flex-shrink: 0; white-space: nowrap; }
.code-row .btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== 主体 ===== */
main { max-width: 760px; margin: 0 auto; padding: 24px 20px 80px; }

/* ===== 仪表盘 ===== */
.hero { text-align: center; padding: 32px 0 12px; }
.hero .date { color: var(--text-3); font-size: 14px; }
.hero .date .streak-inline b { color: var(--brand); font-weight: 700; }
.hero h1 { font-size: 26px; font-weight: 700; margin: 6px 0 4px; }
.hero .sub { color: var(--text-2); font-size: 14px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 28px 0; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.stat .num { font-size: 26px; font-weight: 700; }
.stat .label { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.stat.accent .num { color: var(--brand); }
.stat.warn .num { color: var(--amber); }
.stat.ok .num { color: var(--green); }
.stat.red .num { color: var(--red); }
.stat.clickable { cursor: pointer; transition: border-color .15s, transform .15s; }
.stat.clickable:hover { border-color: var(--brand); transform: translateY(-1px); }
.stat.red.clickable:hover { border-color: var(--red); }

/* 仪表盘：统计详情页 */
.stat-detail .crumb-back { margin-bottom: 16px; }
.stat-detail h2 { font-size: 22px; font-weight: 700; }
.stat-detail .sub { color: var(--text-2); font-size: 14px; margin: 4px 0 16px; }
.stat-detail .word-list { margin-top: 4px; }

.primary-btn {
  display: block;
  width: 100%;
  border: none;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  padding: 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .15s;
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.25);
}
.primary-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.primary-btn:disabled { background: #c7c9d1; box-shadow: none; cursor: not-allowed; transform: none; }
.primary-btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); }

.empty { text-align: center; color: var(--text-3); padding: 48px 0; font-size: 14px; }

/* ===== 学习：模式选择 ===== */
.mode-select { text-align: center; padding-top: 24px; }
.mode-select h2 { font-size: 22px; font-weight: 700; }
.mode-select .sub { color: var(--text-2); font-size: 14px; margin: 6px 0 28px; }
.mode-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.mode-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 16px;
  cursor: pointer;
  transition: all .15s;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.mode-card:hover { border-color: #c7d2fe; transform: translateY(-2px); }
.mode-card .icon { font-size: 32px; }
.mode-card .name { font-weight: 700; font-size: 16px; }
.mode-card small { color: var(--text-3); font-size: 12px; }

/* ===== 学习：出题 ===== */
.study-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.study-head .progress { color: var(--text-2); font-size: 14px; }
.study-head .close { border: none; background: none; color: var(--text-2); font-size: 14px; cursor: pointer; }

.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px 24px;
  text-align: center;
}
.q-tag { display: inline-block; font-size: 12px; color: var(--brand); background: var(--brand-soft); padding: 4px 14px; border-radius: 999px; margin-bottom: 20px; }
.q-word { font-size: 40px; font-weight: 700; letter-spacing: -0.5px; }
.q-phonetic { color: var(--text-3); font-size: 16px; margin-top: 6px; }
.q-meaning { font-size: 26px; font-weight: 600; line-height: 1.4; margin: 8px 0; }
.q-hint { color: var(--text-3); font-size: 13px; margin: 14px 0 4px; }
.q-listen { margin: 10px 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.speaker-btn {
  border: 1px solid var(--border);
  background: var(--brand-soft);
  color: var(--brand);
  width: 64px; height: 64px;
  border-radius: 50%;
  font-size: 28px;
  cursor: pointer;
  transition: all .12s;
  line-height: 1;
}
.speaker-btn:hover { transform: scale(1.06); }
.speaker-btn.small { width: 40px; height: 40px; font-size: 18px; }

.q-input {
  width: 100%;
  border: none;
  border-bottom: 2px solid var(--border);
  border-radius: 0;
  background: none;
  padding: 10px 8px 8px;
  font-size: 22px;
  text-align: center;
  font-family: inherit;
  color: var(--text);
  margin: 12px 0 20px;
  transition: border-color .15s;
}
.q-input:focus {
  outline: none;
  border-bottom-color: var(--brand);
  border-bottom-width: 3px;
  box-shadow: none;
}
.q-input::placeholder { color: var(--text-3); font-size: 16px; }

/* 胶囊确认按钮（出题页） */
.q-confirm-btn {
  display: inline-block;
  border: none;
  background: var(--brand);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 44px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s;
  margin-top: 4px;
}
.q-confirm-btn:focus { outline: none; }
.q-confirm-btn:hover { filter: brightness(1.05); }
.q-confirm-btn:disabled { background: #c7c9d1; cursor: not-allowed; }

/* 顶部栏右侧小按钮组 */
.study-head .head-actions { display: flex; align-items: center; gap: 8px; }
.study-head .pill-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
}
.study-head .pill-btn:hover { border-color: var(--brand); }
.study-head .pill-btn.plain { color: var(--text-2); }

/* ===== 学习：判题结果 ===== */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px 24px;
  text-align: center;
}
.result-card .r-icon { font-size: 52px; line-height: 1; }
.result-card.ok .r-icon { color: var(--green); }
.result-card.no .r-icon { color: var(--red); }
.result-card .r-title { font-size: 22px; font-weight: 700; margin: 10px 0 16px; }
.result-card.ok .r-title { color: var(--green); }
.result-card.no .r-title { color: var(--red); }
.r-answer { font-size: 15px; color: var(--text-2); margin-bottom: 14px; line-height: 1.6; }
.r-answer b { color: var(--text); font-size: 20px; }
.r-answer .ph { color: var(--text-3); font-size: 14px; }
.r-note {
  display: block;
  font-size: 13px;
  color: var(--amber);
  background: var(--amber-soft);
  padding: 8px 14px;
  border-radius: 10px;
  margin: 0 auto 20px;
  width: fit-content;
  max-width: 100%;
}
.sa-actions { display: flex; gap: 10px; margin-top: 4px; }
.result-card .q-confirm-btn { margin-top: 4px; }
.q-confirm-btn.r-green { background: var(--green); color: #fff; border: 1.5px solid var(--green); }
.q-confirm-btn.r-red { background: var(--red); color: #fff; border: 1.5px solid var(--red); }
.syl-inline { font-size: 14px; color: var(--brand); font-weight: 500; }

/* ===== 音节拼图 ===== */
.puzzle-answer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
  min-height: 60px;
  padding: 12px;
  margin: 16px 0 8px;
  background: var(--bg);
  border: 2px dashed var(--border);
  border-radius: 12px;
}
.puzzle-slot {
  width: 60px;
  height: 40px;
  border-radius: 10px;
  background: #fff;
  border: 1px dashed #d1d5db;
  display: inline-block;
}
.puzzle-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 12px;
}
.puzzle-chip {
  border: 1px solid var(--border);
  background: var(--brand-soft);
  color: var(--brand);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s;
  font-family: inherit;
}
.puzzle-chip:hover { transform: translateY(-2px); border-color: #c7d2fe; }
.puzzle-chip.selected { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ===== 磨耳朵 ===== */
.ear-stage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 48px 24px;
  text-align: center;
}
.ear-word { font-size: 44px; font-weight: 700; letter-spacing: -0.5px; }
.ear-phonetic { color: var(--text-3); font-size: 16px; margin-top: 6px; }
.ear-meaning { font-size: 22px; font-weight: 600; color: var(--text); margin-top: 16px; }
.ear-hint { color: var(--text-3); font-size: 13px; margin-top: 20px; }
.ear-controls { display: flex; gap: 10px; margin-top: 28px; }
.ear-controls .btn { flex: 1; }

/* ===== 词库 ===== */
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 20px 0 12px; }
.section-head h2 { font-size: 17px; font-weight: 700; }
.link-btn { border: none; background: none; color: var(--brand); font-size: 14px; font-weight: 500; cursor: pointer; }

.list-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all .12s;
}
.list-item:hover { border-color: #c7d2fe; }
.list-item .name { font-weight: 600; }
.list-item .meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.word-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.word-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow);
}
.word-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  line-height: 24px;
  text-align: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-3);
  font-size: 14px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.word-card:hover .word-del { opacity: 1; }
.word-del:hover { background: #ffecec; color: #e5484d; }
.word-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.word-top .w { font-weight: 600; }
.word-top .ph { color: var(--text-3); font-size: 12px; }
.word-card .m {
  color: var(--text-2);
  font-size: 13px;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== 词库：左边栏 + 右侧 ===== */
main:has(.lib-layout) { max-width: 1080px; }

.lib-layout {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 520px;
  overflow: hidden;
}

.lib-side {
  width: 240px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: #fafbfc;
  display: flex;
  flex-direction: column;
}

.lib-side-actions { display: flex; gap: 8px; padding: 14px; border-bottom: 1px solid var(--border); }
.lib-side-actions .link-btn {
  flex: 1;
  font-size: 13px;
  padding: 7px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
  color: var(--text-2);
}
.lib-side-actions .link-btn:hover { border-color: var(--brand); color: var(--brand); }

.lib-tree { flex: 1; overflow: auto; padding: 8px; position: relative; }

.lib-tree-empty { color: var(--text-3); font-size: 13px; text-align: center; padding: 30px 12px; line-height: 1.8; }

/* 「移到顶层」横条：绝对定位悬浮在树底部，不占文档流，
   避免拖拽时因横条出现/消失导致目录节点整体移动、落点错乱 */
.lib-root-drop {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  z-index: 20;
  font-size: 12px;
  color: var(--brand);
  border: 1px dashed var(--brand);
  border-radius: 8px;
  text-align: center;
  padding: 6px;
  background: var(--brand-soft);
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.lib-root-drop.drop-target { background: #c7d2fe; }

.tree-node {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  user-select: none;
  transition: background .1s;
}
.tree-node:hover { background: #f3f4f6; }
.tree-node.active { background: var(--brand-soft); color: var(--brand); }
.tree-node.dragging { opacity: 0.4; }
.tree-node.drop-target { background: #e0e7ff; outline: 2px solid var(--brand); outline-offset: -2px; }
.drag-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
  white-space: nowrap;
}
.tree-node .tree-caret { width: 14px; flex-shrink: 0; color: var(--text-3); font-size: 11px; text-align: center; }
.tree-node .tree-caret.spacer { visibility: hidden; }
.tree-node .tree-icon { flex-shrink: 0; font-size: 14px; }
.tree-node .tree-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-node .tree-count { flex-shrink: 0; font-size: 11px; color: var(--text-3); background: #eef0f3; border-radius: 10px; padding: 1px 7px; }
.tree-node.active .tree-count { background: #e0e7ff; color: var(--brand); }

.tree-node.inline { cursor: default; }
.tree-node.inline:hover { background: transparent; }
.tree-node .inline-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--brand);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 14px;
  outline: none;
  background: var(--surface);
  color: var(--text);
}
.study-toggle { width: 30px; height: 16px; border-radius: 999px; background: #cbd5e1; position: relative; cursor: pointer; flex-shrink: 0; border: none; padding: 0; transition: background .15s; }
.study-toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: left .15s; }
.study-toggle.on { background: #22c55e; }
.study-toggle.on::after { left: 16px; }

.lib-main { flex: 1; min-width: 0; padding: 20px 24px; overflow: auto; }
.lib-main-empty { color: var(--text-3); font-size: 14px; text-align: center; padding: 60px 20px; }
.lib-list-loading { color: var(--text-3); font-size: 14px; padding: 40px 0; text-align: center; }

.lib-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.lib-detail-head h2 { font-size: 18px; font-weight: 700; }
.lib-breadcrumb { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.lib-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all .12s;
  background: var(--surface);
}
.lib-card:hover { border-color: #c7d2fe; box-shadow: var(--shadow); }
.lib-card-icon { font-size: 24px; }
.lib-card-name { font-weight: 600; margin-top: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-card-name-line { display: flex; align-items: center; gap: 8px; margin-top: 8px; min-width: 0; }
.lib-card-name-line .lib-card-name { margin-top: 0; flex: 1; min-width: 0; }
.lib-card-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ===== 表单 / 弹层 ===== */
.modal-mask { position: fixed; inset: 0; background: rgba(17, 24, 39, 0.4); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: var(--surface); border-radius: 18px; padding: 24px; width: 100%; max-width: 520px; max-height: 84vh; overflow: auto; box-shadow: 0 20px 60px rgba(16, 24, 40, 0.25); }
.modal.modal-lg { max-width: 780px; }
.modal h3 { font-size: 17px; margin-bottom: 4px; }
.modal-titlebar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.modal-titlebar h3 { margin-bottom: 0; flex: 1; }
.modal-x { border: none; background: none; color: var(--text-3); font-size: 22px; line-height: 1; cursor: pointer; padding: 2px 8px; border-radius: 8px; flex: none; }
.modal-x:hover { color: var(--text); background: #f0f1f5; }
.book-confirm-head { font-size: 14px; margin: 4px 0 12px; color: var(--text-2); }
.book-unit-list { list-style: none; margin: 0 0 8px; padding: 0; max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.book-unit-list li { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.book-unit-list li:last-child { border-bottom: none; }
.book-unit-list .bc { color: var(--text-3); font-size: 12px; }
.dup-tag { color: #b91c1c; background: #fee2e2; font-size: 12px; padding: 1px 6px; border-radius: 4px; }
.modal .hint { font-size: 13px; color: var(--text-3); margin-bottom: 16px; }

/* 豆包智能整理引导卡片 */
.ai-assist {
  margin-bottom: 14px; padding: 12px 14px;
  background: var(--brand-soft); border: 1px solid #c7d2fe; border-radius: 10px;
}
.ai-assist-title { font-size: 14px; font-weight: 600; color: var(--brand); margin-bottom: 4px; }
.ai-assist-steps { font-size: 12.5px; color: var(--text-2); line-height: 1.55; margin-bottom: 10px; }
.ai-assist .btn { flex: none; font-size: 13px; padding: 7px 14px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  resize: vertical;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12); }
.field textarea { min-height: 140px; line-height: 1.5; }

.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.btn {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s;
}
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.05); }
.btn:hover { background: #f3f4f6; }
.btn.primary:hover { background: var(--brand); }
.btn.danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn.danger:hover { background: #b91c1c; filter: brightness(1.05); }
.link-btn.danger { color: #dc2626; }
.link-btn.danger:hover { opacity: 0.8; }
.modal .hint.warn { color: #b91c1c; }

/* ===== 导入：教材库选择器 ===== */
.import-tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.import-tab { border: none; background: none; padding: 8px 14px; font-size: 14px; font-weight: 500; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; }
.import-tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.crumb { font-size: 13px; color: var(--text-3); margin-bottom: 12px; }
.crumb-back { border: none; background: none; color: var(--brand); font-size: 13px; cursor: pointer; padding: 0; display: inline-flex; align-items: center; gap: 4px; }
.crumb-back svg { flex: none; }
.course-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.course-card:hover { border-color: var(--brand); background: #f5f6ff; }
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.course-grid .course-card { margin-bottom: 0; }
.course-name { font-size: 15px; font-weight: 600; }
.course-desc { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.unit-preview { border: 1px solid var(--border); border-radius: 12px; padding: 6px; max-height: 40vh; overflow: auto; margin-bottom: 12px; }
.unit-preview-head { font-size: 13px; color: var(--text-3); padding: 4px 8px 8px; }
.unit-word { display: flex; gap: 8px; align-items: baseline; padding: 6px 8px; border-radius: 8px; }
.unit-word:nth-child(odd) { background: #fafafa; }
.unit-word b { min-width: 90px; }
.unit-word .ph { color: var(--text-3); font-size: 12px; }
.unit-word .m { color: var(--text-2); font-size: 13px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
.toast.show { opacity: 1; }

/* 词表详情：背这个词表主按钮 */
.link-btn.primary { color: #fff; background: var(--brand); padding: 6px 14px; border-radius: 8px; }
.link-btn.primary:hover { filter: brightness(1.05); }

/* 自由模式：记进度 / 纯刷不记 选择 */
.free-mode-options { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.free-mode-card {
  display: flex; flex-direction: column; gap: 4px;
  text-align: left; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.free-mode-card:hover { border-color: var(--brand); background: var(--brand-soft); }
.free-mode-card.primary { border-color: var(--brand); }
.fm-name { font-size: 15px; font-weight: 600; color: var(--text); }
.fm-desc { font-size: 13px; color: var(--text-3); }

/* 错题本 */
.wrong-book { max-width: 720px; margin: 0 auto; }
.wrong-book .crumb-back { margin-bottom: 12px; }
.wrong-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.wrong-tab {
  border: none; background: none; padding: 10px 16px;
  font-size: 14px; color: var(--text-3); cursor: pointer;
  border-bottom: 2px solid transparent;
}
.wrong-tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.wrong-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 16px; }
.wrong-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.wi-main { min-width: 0; }
.wi-word { font-size: 16px; font-weight: 600; color: var(--text); }
.wi-word .ph { font-size: 12px; color: var(--text-3); font-weight: 400; }
.wi-meaning { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.wi-badge {
  flex: none; font-size: 12px; color: #dc2626; background: #fef2f2;
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}

/* 学习首页：入口选择 */
.study-home { max-width: 720px; margin: 0 auto; padding-top: 16px; }
.study-home h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.study-home .sub { color: var(--text-2); font-size: 14px; margin-bottom: 20px; }

/* 学习首页标题行 + 按步骤开关 */
.study-home-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.study-home-head h2 { margin-bottom: 0; }
.step-switch { display: flex; align-items: center; gap: 8px; }
.step-switch-label { font-size: 13px; color: var(--text-2); }
.step-switch-btn {
  position: relative; width: 44px; height: 24px; border-radius: 12px;
  border: none; cursor: pointer; background: #d1d5db; transition: background .2s;
}
.step-switch-btn.on { background: var(--brand); }
.step-switch-thumb {
  position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.step-switch-btn.on .step-switch-thumb { left: 22px; }

/* 步骤过渡页 */
.step-transition { text-align: center; padding-top: 60px; }
.step-transition .st-icon {
  display: inline-block; font-size: 14px; font-weight: 700; color: var(--brand);
  background: var(--brand-soft); padding: 6px 16px; border-radius: 20px; margin-bottom: 16px;
}
.step-transition h2 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.step-transition .sub { color: var(--text-2); font-size: 15px; margin-bottom: 28px; }
.step-transition .primary-btn { max-width: 260px; margin: 0 auto; }

.study-mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.study-mode-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.study-mode-card.ai { border-top: 3px solid var(--brand); }
.study-mode-card.free { border-top: 3px solid #22c55e; }
.study-mode-card.wrong-pending { border-top: 3px solid #dc2626; }
.study-mode-card.wrong-calendar { border-top: 3px solid #f59e0b; }
.smc-name { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.smc-desc { font-size: 13px; color: var(--text-2); line-height: 1.6; margin-bottom: 16px; min-height: 42px; }
.smc-stats { display: flex; gap: 24px; margin-bottom: 18px; }
.smc-stat b { display: block; font-size: 24px; font-weight: 700; color: var(--text); }
.smc-stat span { font-size: 12px; color: var(--text-3); }
.study-mode-card .btn { flex: none; margin-top: auto; }

/* 自由模式：选词表 */
.free-pick { max-width: 720px; margin: 0 auto; padding-top: 16px; }
.free-pick .crumb-back { margin-bottom: 12px; }
.fp-titlebar { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.fp-titlebar h2 { font-size: 20px; font-weight: 700; margin: 0; margin-right: auto; }
.fp-titlebar .fp-opt-label { flex: none; }
.free-pick .sub { color: var(--text-2); font-size: 14px; margin-bottom: 16px; }
.fp-tree { display: flex; flex-direction: column; }
.fp-folder {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 600; color: var(--text);
  padding: 8px 0; cursor: pointer; user-select: none;
}
.fp-folder:hover { color: var(--brand); }
.fp-caret { flex: none; width: 14px; font-size: 12px; color: var(--text-3); text-align: center; }
.fp-list {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.fp-folder .tree-icon, .fp-list .tree-icon { font-size: 14px; flex: none; }
.fp-name { flex: 1; font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fp-count { flex: none; font-size: 12px; color: var(--text-3); }
.fp-btn { flex: none; padding: 6px 16px; font-size: 13px; }

.fp-opt-label { font-size: 13px; color: var(--text); flex: none; }
.fp-help-wrap { position: relative; display: inline-flex; flex: none; }
.fp-help {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-3); font-size: 12px; line-height: 1;
  cursor: help; padding: 0; display: inline-flex; align-items: center; justify-content: center;
}
.fp-help-tip {
  position: absolute; bottom: 130%; left: 50%; transform: translateX(-50%);
  width: 220px; padding: 8px 10px;
  background: #1f2430; color: #fff; font-size: 12px; line-height: 1.5;
  border-radius: 8px; opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .15s; z-index: 20;
}
.fp-help:hover + .fp-help-tip, .fp-help:focus + .fp-help-tip { opacity: 1; visibility: visible; }

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .q-word { font-size: 32px; }
  .q-meaning { font-size: 22px; }
  .lib-layout { flex-direction: column; min-height: 0; }
  .lib-side { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .lib-tree { max-height: 240px; }
}
