/* ============ 中学生学习助手 全局样式 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #4f6ef7;
  --primary-dark: #3d5ae0;
  --primary-light: #e8edff;
  --green: #22c55e;
  --green-light: #e6f9ee;
  --orange: #f97316;
  --orange-light: #fff3e6;
  --red: #ef4444;
  --red-light: #feecec;
  --ink: #1f2430;
  --ink-2: #5b6270;
  --ink-3: #9aa1b1;
  --bg: #f4f6fb;
  --card: #ffffff;
  --line: #e6e9f2;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(31, 36, 48, .06);
  --shadow-lg: 0 12px 32px rgba(31, 36, 48, .14);
}
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  overflow: hidden;
}
#app { display: flex; height: 100vh; }

/* ============ 侧边栏 ============ */
.sidebar {
  width: 232px; flex-shrink: 0;
  background: linear-gradient(180deg, #25315c 0%, #1d2747 100%);
  color: #dbe2f5;
  display: flex; flex-direction: column;
  padding: 18px 12px 14px;
}
.logo { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; }
.logo-icon { font-size: 30px; }
.logo-title { font-size: 16px; font-weight: 700; color: #fff; letter-spacing: .5px; }
.logo-sub { font-size: 11px; color: #8d98c0; letter-spacing: 2px; margin-top: 2px; }
.nav { flex: 1; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border: none; background: none; cursor: pointer;
  color: #cdd5ee; font-size: 14px; border-radius: 10px; text-align: left;
  transition: all .15s; font-family: inherit;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; box-shadow: 0 4px 14px rgba(79,110,247,.4); }
.nav-ico { font-size: 17px; width: 22px; text-align: center; }
.badge {
  margin-left: auto; background: var(--red); color: #fff; font-size: 11px;
  padding: 1px 8px; border-radius: 20px; font-weight: 600; min-width: 20px; text-align: center;
}
.sidebar-foot { padding: 10px 8px 0; font-size: 12px; color: #7d89b4; }
.save-hint { opacity: .9; }

/* ============ 主区域 ============ */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 62px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; background: #fff; border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 19px; font-weight: 700; }
.top-stats { display: flex; gap: 10px; }
.stat-chip {
  background: var(--bg); border: 1px solid var(--line); border-radius: 20px;
  padding: 5px 12px; font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 5px;
}
.stat-chip b { color: var(--ink); font-size: 13px; }
.chip-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.content { flex: 1; overflow-y: auto; padding: 24px 26px 40px; }

/* ============ 通用组件 ============ */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card-title .sub { font-size: 12px; color: var(--ink-3); font-weight: 400; }
.btn {
  border: none; border-radius: 10px; padding: 9px 18px; font-size: 14px; cursor: pointer;
  font-family: inherit; transition: all .15s; font-weight: 600;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.green { background: var(--green); color: #fff; }
.btn.green:hover { filter: brightness(.95); }
.btn.ghost { background: #fff; color: var(--ink-2); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn.danger { background: var(--red-light); color: var(--red); }
.btn.sm { padding: 5px 12px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.tag.blue { background: var(--primary-light); color: var(--primary); }
.tag.green { background: var(--green-light); color: #15803d; }
.tag.orange { background: var(--orange-light); color: #c2410c; }
.tag.red { background: var(--red-light); color: var(--red); }
.tag.gray { background: #f1f2f7; color: var(--ink-2); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.empty {
  text-align: center; color: var(--ink-3); padding: 42px 0; font-size: 14px; line-height: 1.9;
}
.empty .big { font-size: 44px; display: block; margin-bottom: 8px; }

/* ============ 首页 ============ */
.hero {
  background: linear-gradient(120deg, #4f6ef7 0%, #7c5cf5 60%, #9a6bf0 100%);
  border-radius: var(--radius); padding: 26px 30px; color: #fff;
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: 0 10px 30px rgba(79,110,247,.3); margin-bottom: 20px;
}
.hero h2 { font-size: 22px; margin-bottom: 8px; }
.hero p { opacity: .9; font-size: 14px; }
.hero .btn.white { background: #fff; color: var(--primary); }
.hero .btn.white:hover { background: var(--primary-light); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat-card .num { font-size: 28px; font-weight: 800; margin-top: 4px; }
.stat-card .lbl { font-size: 12px; color: var(--ink-3); }
.stat-card .num.green { color: var(--green); } .stat-card .num.blue { color: var(--primary); }
.stat-card .num.orange { color: var(--orange); } .stat-card .num.red { color: var(--red); }
.chart-bar { display: flex; align-items: flex-end; gap: 8px; height: 130px; padding-top: 8px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.chart-col .bar {
  width: 70%; background: linear-gradient(180deg, #6d8bff, #4f6ef7); border-radius: 6px 6px 0 0;
  min-height: 4px; transition: height .4s;
}
.chart-col .bar.today { background: linear-gradient(180deg, #34d399, #22c55e); }
.chart-col .day { font-size: 11px; color: var(--ink-3); }
.chart-col .val { font-size: 11px; color: var(--ink-2); font-weight: 600; }

/* ============ 课本学习 ============ */
.book-tree { display: flex; gap: 16px; }
.book-col { flex: 1; min-width: 0; }
.book-col .col-title { font-size: 13px; font-weight: 700; color: var(--ink-3); margin-bottom: 10px; }
.tree-group { margin-bottom: 8px; }
.tree-group > .tree-head {
  padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px;
}
.tree-group > .tree-head:hover { border-color: var(--primary); color: var(--primary); }
.tree-group.open > .tree-head { color: var(--primary); border-color: var(--primary); }
.tree-group.open > .tree-head .arrow { transform: rotate(90deg); }
.arrow { transition: transform .15s; font-size: 11px; }
.tree-children { display: none; padding-left: 6px; }
.tree-group.open > .tree-children { display: block; }
.tree-item {
  padding: 8px 12px; margin: 4px 0; border-radius: 8px; cursor: pointer; font-size: 13px;
  display: flex; align-items: center; gap: 8px; color: var(--ink-2);
}
.tree-item:hover { background: var(--primary-light); color: var(--primary); }
.tree-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.tree-item .cnt { margin-left: auto; font-size: 11px; opacity: .7; }

/* 课文详情 */
.lesson-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.lesson-head h2 { font-size: 21px; }
.lesson-text {
  background: #fbfcff; border: 1px solid var(--line); border-radius: 12px;
  padding: 18px 20px; line-height: 2; font-size: 15px; white-space: pre-wrap;
}
.lesson-text .en { font-family: Georgia, "Times New Roman", serif; font-size: 17px; line-height: 2.1; }
.sentence { padding: 2px 6px; border-radius: 6px; cursor: pointer; transition: background .15s; }
.sentence:hover { background: var(--primary-light); }
.sentence.playing { background: var(--primary); color: #fff; }
.keypoint { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); align-items: flex-start; }
.keypoint:last-child { border-bottom: none; }
.keypoint .kp-idx {
  width: 24px; height: 24px; border-radius: 8px; background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.audio-bar { display: flex; align-items: center; gap: 10px; background: var(--primary-light); border-radius: 12px; padding: 12px 16px; flex-wrap: wrap; }
.audio-bar .rate { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.audio-bar select, .audio-bar input[type=range] { accent-color: var(--primary); }

/* ============ 练习 ============ */
.q-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.q-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.q-type { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 16px; }
.q-type.choice { background: var(--primary-light); color: var(--primary); }
.q-type.fill { background: var(--green-light); color: #15803d; }
.q-type.judge { background: var(--orange-light); color: #c2410c; }
.q-type.word { background: #f3e8ff; color: #7c3aed; }
.q-source { font-size: 12px; color: var(--ink-3); }
.q-text { font-size: 16px; line-height: 1.9; margin-bottom: 16px; }
.q-text .blank { display: inline-block; min-width: 90px; border-bottom: 2px solid var(--primary); color: var(--primary); font-weight: 700; text-align: center; }
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  border: 2px solid var(--line); border-radius: 12px; padding: 12px 16px; cursor: pointer;
  font-size: 14px; transition: all .15s; display: flex; align-items: center; gap: 10px;
}
.option:hover { border-color: var(--primary); background: var(--primary-light); }
.option .opt-key {
  width: 26px; height: 26px; border-radius: 8px; background: var(--bg); display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 13px; color: var(--ink-2); flex-shrink: 0;
}
.option.correct { border-color: var(--green); background: var(--green-light); }
.option.correct .opt-key { background: var(--green); color: #fff; }
.option.wrong { border-color: var(--red); background: var(--red-light); }
.option.wrong .opt-key { background: var(--red); color: #fff; }
.option.disabled { pointer-events: none; }
.fill-answer input {
  width: 100%; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; font-size: 15px; outline: none;
  font-family: inherit;
}
.fill-answer input:focus { border-color: var(--primary); }
.judge-btns { display: flex; gap: 12px; }
.judge-btns .btn { flex: 1; padding: 14px; font-size: 15px; }
.result-banner { border-radius: 12px; padding: 14px 18px; margin-top: 14px; display: none; }
.result-banner.show { display: block; }
.result-banner.right { background: var(--green-light); color: #15803d; }
.result-banner.wrong { background: var(--red-light); color: var(--red); }
.result-banner .ans { font-weight: 700; margin-top: 6px; }
.result-banner .explain { margin-top: 8px; color: var(--ink-2); line-height: 1.8; }
.practice-progress { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.progress-track { flex: 1; height: 8px; background: var(--line); border-radius: 8px; overflow: hidden; }
.progress-track .fill { height: 100%; background: var(--primary); border-radius: 8px; transition: width .3s; }
.progress-info { font-size: 13px; color: var(--ink-2); font-weight: 600; }

/* ============ 错题本 ============ */
.error-item { display: flex; gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; margin-bottom: 12px; box-shadow: var(--shadow); }
.error-item .ei-main { flex: 1; min-width: 0; }
.error-item .ei-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; justify-content: center; }
.error-item .q-preview { color: var(--ink-2); line-height: 1.7; margin-top: 6px; font-size: 13px; }
.error-item .q-preview .blank { color: var(--primary); font-weight: 700; }
.wrong-times { font-size: 12px; color: var(--ink-3); }

/* ============ 单词 ============ */
.word-table { width: 100%; border-collapse: collapse; }
.word-table th { text-align: left; font-size: 12px; color: var(--ink-3); padding: 8px 10px; border-bottom: 1px solid var(--line); }
.word-table td { padding: 10px; border-bottom: 1px solid #f0f2f9; font-size: 14px; }
.word-table tr:hover { background: #fafbff; }
.word-en { font-weight: 700; font-size: 15px; }
.word-ph { color: var(--ink-3); font-size: 12px; }
.state-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.word-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; text-align: center; }
.word-card .w-en { font-size: 30px; font-weight: 800; margin: 10px 0 4px; font-family: Georgia, serif; }
.word-card .w-ph { color: var(--ink-3); margin-bottom: 18px; }
.word-card .w-input { width: 90%; padding: 12px; border: 2px solid var(--line); border-radius: 12px; font-size: 18px; text-align: center; outline: none; font-family: inherit; }
.word-card .w-input:focus { border-color: var(--primary); }

/* ============ 学习重点 ============ */
.kp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.kp-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.kp-card h4 { font-size: 15px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.kp-card ul { list-style: none; }
.kp-card li { padding: 6px 0 6px 18px; position: relative; font-size: 13px; line-height: 1.7; color: var(--ink-2); }
.kp-card li::before { content: "•"; position: absolute; left: 2px; color: var(--primary); font-weight: 700; }

/* ============ AI 出题 ============ */
.ai-panel { display: grid; grid-template-columns: 300px 1fr; gap: 20px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink-2); }
.form-group select, .form-group input[type=text], .form-group input[type=password] {
  width: 100%; padding: 9px 12px; border: 2px solid var(--line); border-radius: 10px; font-size: 14px; outline: none; font-family: inherit; background: #fff;
}
.form-group select:focus, .form-group input:focus { border-color: var(--primary); }
.check-list { display: flex; flex-wrap: wrap; gap: 8px; }
.check-chip { border: 2px solid var(--line); border-radius: 20px; padding: 6px 14px; cursor: pointer; font-size: 13px; user-select: none; }
.check-chip.on { border-color: var(--primary); background: var(--primary-light); color: var(--primary); font-weight: 600; }
.gen-list { display: flex; flex-direction: column; gap: 10px; }
.gen-item { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: #fff; }
.gen-item .gq { font-size: 14px; line-height: 1.8; }
.gen-item .ga { margin-top: 8px; font-size: 13px; color: var(--green); font-weight: 600; }
.gen-item .gx { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

/* ============ 弹窗 ============ */
.modal-mask { position: fixed; inset: 0; background: rgba(20, 24, 40, .45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 18px; box-shadow: var(--shadow-lg); padding: 26px; width: 520px; max-width: 94vw; max-height: 88vh; overflow-y: auto; }
.modal.wide { width: 720px; }
.modal.small { width: 400px; }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 14px; }
.modal-body { line-height: 1.8; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ============ Toast ============ */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: #232a3d; color: #fff; padding: 12px 22px; border-radius: 12px; font-size: 14px;
  opacity: 0; transition: all .3s; z-index: 200; box-shadow: var(--shadow-lg); pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ 设置 ============ */
.set-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--line); gap: 16px; flex-wrap: wrap; }
.set-row:last-child { border-bottom: none; }
.set-row .info { flex: 1; min-width: 240px; }
.set-row .info h4 { font-size: 14px; margin-bottom: 3px; }
.set-row .info p { font-size: 12px; color: var(--ink-3); line-height: 1.6; }
.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: #cfd4e3; border-radius: 20px; transition: .2s; cursor: pointer; }
.switch .slider::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ============ 滚动条 ============ */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #c9cfdd; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #aab3c7; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 单词游戏 ============ */
.word-card .options { margin-top: 14px; text-align: left; }
.game-set-title { font-size: 14px; font-weight: 700; color: var(--ink-2); margin: 18px 0 8px; }
.game-set-title:first-of-type { margin-top: 0; }

/* ============ 中途结束续作 / 模拟考试 ============ */
.resume-card { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border-color: var(--orange); background: #fff7ed; margin-bottom: 14px; }
.option.chosen, .judge-btns .chosen { border-color: var(--primary); background: var(--primary-light); }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.history-item:hover { border-color: var(--primary); background: var(--primary-light); }
.exam-score { font-weight: 800; font-size: 18px; white-space: nowrap; }
.exam-score.pass { color: var(--green); }
.exam-score.fail { color: var(--red); }
.exam-detail-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.exam-detail-item { border: 1px solid var(--line); border-left-width: 4px; border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.7; }
.exam-detail-item.ok { border-left-color: var(--green); }
.exam-detail-item.bad { border-left-color: var(--red); background: #fef5f5; }

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