:root {
  --primary: #4f8cff;
  --primary-dark: #3a6fd9;
  --primary-light: #e8f0ff;
  --success: #4caf85;
  --warning: #ff9933;
  --danger: #ff5d6c;
  --info: #9c6cff;
  --bg: #f5f8fc;
  --card: #ffffff;
  --text: #2c3e50;
  --text-light: #7c8a99;
  --border: #e3e8ef;
  --shadow: 0 2px 12px rgba(79,140,255,0.08);
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }
.hidden { display: none !important; }

/* 顶部导航 */
.topbar {
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 10px 16px; display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow);
}
.brand { font-size: 18px; font-weight: 700; color: var(--primary); white-space: nowrap; }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.nav-item {
  padding: 6px 14px; border-radius: 18px; color: var(--text-light);
  font-size: 14px; white-space: nowrap; transition: all 0.2s;
}
.nav-item:hover { background: var(--primary-light); color: var(--primary); }
.nav-item.active { background: var(--primary); color: white; }
.user-area { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-light); }
.btn-link { color: var(--primary); padding: 4px 8px; border-radius: 6px; }
.btn-link:hover { background: var(--primary-light); }

/* 登录 */
.auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: linear-gradient(135deg, #e8f0ff 0%, #f5f8fc 100%);
}
.auth-card {
  background: var(--card); padding: 36px; border-radius: 18px;
  box-shadow: 0 8px 32px rgba(79,140,255,0.12); width: 100%; max-width: 420px;
}
.auth-logo { font-size: 44px; text-align: center; margin-bottom: 8px; }
.auth-card h1 { font-size: 22px; text-align: center; margin-bottom: 6px; }
.auth-card .subtitle { text-align: center; color: var(--text-light); font-size: 13px; margin-bottom: 22px; }
.auth-tabs { display: flex; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.auth-tabs .tab { flex: 1; padding: 10px; border-radius: 8px; color: var(--text-light); font-size: 14px; }
.auth-tabs .tab.active { background: var(--card); color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }
.form-row { margin-bottom: 12px; }
.form-row label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-light); }
.form-row input, .form-row select {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: 8px; background: white; transition: border-color 0.2s;
}
.form-row input:focus, .form-row select:focus { outline: none; border-color: var(--primary); }
.btn-primary {
  background: var(--primary); color: white; padding: 12px 24px;
  border-radius: 8px; font-size: 15px; font-weight: 600; transition: background 0.2s;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: #c0c8d0; cursor: not-allowed; }
.btn-block { width: 100%; }
.hint { text-align: center; font-size: 12px; color: var(--text-light); margin-top: 14px; }

/* 通用组件 */
.btn { padding: 9px 16px; border-radius: 8px; font-size: 14px; transition: all 0.15s; display: inline-flex; align-items: center; gap: 6px; }
.btn-secondary { background: var(--primary-light); color: var(--primary); }
.btn-secondary:hover { background: #d4e2ff; }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-ghost { background: transparent; color: var(--text-light); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.container { max-width: 1200px; margin: 0 auto; padding: 18px; }
.page-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.page-subtitle { color: var(--text-light); font-size: 13px; margin-bottom: 18px; }

/* 首页 */
.hero {
  background: linear-gradient(135deg, #4f8cff 0%, #6c8eff 100%);
  color: white; border-radius: var(--radius); padding: 22px; margin-bottom: 14px;
}
.hero h2 { font-size: 21px; margin-bottom: 4px; }
.hero p { opacity: 0.92; font-size: 14px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); text-align: center; }
.stat .num { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat .label { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.task-list { display: grid; gap: 8px; }
.task {
  background: var(--card); padding: 12px 14px; border-radius: 10px;
  display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow); border-left: 4px solid var(--primary);
}
.task.danger { border-left-color: var(--danger); }
.task.warning { border-left-color: var(--warning); }
.task.success { border-left-color: var(--success); }
.task .icon { width: 34px; height: 34px; background: var(--primary-light); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.task.danger .icon { background: #ffe2e5; }
.task.warning .icon { background: #fff0d9; }
.task.success .icon { background: #d9f2e7; }
.task .body { flex: 1; }
.task .t { font-weight: 600; font-size: 14px; }
.task .d { color: var(--text-light); font-size: 12px; }
.task .action { white-space: nowrap; }

.subject-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.subject {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); cursor: pointer; transition: transform 0.15s;
  border-left: 4px solid var(--primary);
}
.subject:hover { transform: translateY(-2px); }
.subject.math { border-left-color: #ff9933; }
.subject.chinese { border-left-color: #ff5d6c; }
.subject.english { border-left-color: #4caf85; }
.subject.science { border-left-color: #9c6cff; }
.subject h3 { font-size: 16px; margin-bottom: 4px; }
.subject .meta { color: var(--text-light); font-size: 12px; }
.subject .bar { margin-top: 8px; background: var(--bg); border-radius: 4px; height: 5px; overflow: hidden; }
.subject .bar-fill { height: 100%; background: var(--primary); transition: width 0.3s; }
.subject.math .bar-fill { background: #ff9933; }
.subject.chinese .bar-fill { background: #ff5d6c; }
.subject.english .bar-fill { background: #4caf85; }
.subject.science .bar-fill { background: #9c6cff; }

/* 知识点列表 */
.kp-list { display: grid; gap: 8px; }
.kp-item {
  background: var(--card); padding: 14px 16px; border-radius: 10px;
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: var(--shadow); cursor: pointer; transition: transform 0.15s;
}
.kp-item:hover { transform: translateX(4px); }
.kp-title { font-weight: 600; font-size: 15px; }
.kp-meta { font-size: 12px; color: var(--text-light); margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
.kp-tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; }
.kp-tag.unlearned { background: #e3e8ef; color: var(--text-light); }
.kp-tag.learning { background: #fff0d9; color: var(--warning); }
.kp-tag.weak { background: #ffe2e5; color: var(--danger); }
.kp-tag.mastered { background: #d9f2e7; color: var(--success); }
.kp-tag.core { background: #f0e0ff; color: var(--info); }

/* 知识点详情 */
.detail-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.detail-tab { padding: 10px 16px; font-size: 14px; color: var(--text-light); border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.detail-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.summary-box {
  background: linear-gradient(135deg, #e8f0ff 0%, #f5f8fc 100%);
  border-radius: 10px; padding: 14px; margin-bottom: 12px; line-height: 1.7;
}
.kp-points { list-style: none; padding: 0; }
.kp-points li { padding: 7px 12px; background: var(--bg); margin-bottom: 5px; border-radius: 6px; font-size: 14px; border-left: 3px solid var(--primary); }
.example-box { background: #fff8e1; padding: 11px; border-radius: 6px; font-size: 14px; border-left: 3px solid var(--warning); margin-top: 10px; }

/* 费曼 */
.fe textarea { width: 100%; min-height: 110px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; resize: vertical; }
.fe-tip { background: var(--primary-light); color: var(--primary); padding: 10px; border-radius: 8px; font-size: 13px; margin-bottom: 10px; }
.fe-tip b { color: var(--primary-dark); }
.score-row { display: flex; gap: 6px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
.score-btn { padding: 6px 12px; border: 1px solid var(--border); border-radius: 16px; background: white; cursor: pointer; font-size: 13px; }
.score-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.missed { background: #ffe2e5; padding: 8px 12px; border-radius: 6px; margin-top: 8px; font-size: 13px; color: var(--danger); }
.fe-record { background: var(--bg); padding: 10px; border-radius: 6px; margin-top: 8px; font-size: 13px; }
.fe-record .meta { color: var(--text-light); font-size: 11px; margin-bottom: 4px; }
.fe-record.weak { border-left: 3px solid var(--danger); }

/* 测验 */
.q-progress { height: 5px; background: var(--bg); border-radius: 3px; margin-bottom: 16px; overflow: hidden; }
.q-progress-bar { height: 100%; background: var(--primary); transition: width 0.3s; }
.q-card { background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 14px; }
.q-type { display: inline-block; padding: 2px 8px; background: var(--primary-light); color: var(--primary); border-radius: 8px; font-size: 11px; margin-bottom: 8px; }
.q-type.variant { background: #fff0d9; color: var(--warning); }
.q-content { font-size: 17px; font-weight: 600; margin-bottom: 14px; line-height: 1.6; }
.q-options { display: grid; gap: 8px; }
.q-option {
  padding: 11px 14px; background: var(--bg); border: 2px solid transparent;
  border-radius: 10px; cursor: pointer; font-size: 15px; transition: all 0.15s;
}
.q-option:hover { border-color: var(--primary); }
.q-option.selected { border-color: var(--primary); background: var(--primary-light); }
.q-option.correct { border-color: var(--success); background: #d9f2e7; }
.q-option.wrong { border-color: var(--danger); background: #ffe2e5; }
.q-input { width: 100%; padding: 11px; font-size: 15px; border: 1px solid var(--border); border-radius: 8px; }
.q-result-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.q-result-row:last-child { border-bottom: none; }
.q-result-row .status { font-weight: 600; }
.q-result-row .status.right { color: var(--success); }
.q-result-row .status.wrong { color: var(--danger); }
.quiz-type-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.quiz-type-card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); cursor: pointer; transition: transform 0.15s;
}
.quiz-type-card:hover { transform: translateY(-2px); }
.quiz-type-card h4 { font-size: 16px; margin-bottom: 4px; }
.quiz-type-card p { color: var(--text-light); font-size: 12px; }
.quiz-type-card .badge { display: inline-block; padding: 2px 8px; background: var(--primary-light); color: var(--primary); border-radius: 8px; font-size: 11px; margin-top: 6px; }

/* 错题本 */
.wrong-card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow); border-left: 4px solid var(--danger); }
.wrong-card.cleared { border-left-color: var(--success); opacity: 0.75; }
.wrong-meta { display: flex; gap: 6px; font-size: 12px; color: var(--text-light); margin-bottom: 8px; flex-wrap: wrap; }
.wrong-meta .tag { padding: 2px 8px; background: var(--bg); border-radius: 10px; }
.wrong-meta .tag.error { background: #ffe2e5; color: var(--danger); }
.wrong-meta .tag.cleared { background: #d9f2e7; color: var(--success); }
.wrong-question { font-weight: 600; margin-bottom: 8px; }
.wrong-explanation { background: var(--bg); padding: 10px; border-radius: 6px; font-size: 13px; margin-top: 8px; color: var(--text-light); }
.wrong-progress { font-size: 11px; color: var(--text-light); margin-top: 4px; }
.wrong-progress .check { color: var(--success); }
.wrong-progress .pending { color: var(--warning); }

/* 数据 */
.chart-card { background: var(--card); border-radius: var(--radius); padding: 18px; margin-bottom: 12px; box-shadow: var(--shadow); }
.bar-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.bar-label { width: 70px; font-size: 13px; color: var(--text-light); }
.bar-track { flex: 1; background: var(--bg); border-radius: 4px; height: 16px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.4s; }
.bar-fill.math { background: #ff9933; }
.bar-fill.chinese { background: #ff5d6c; }
.bar-fill.english { background: #4caf85; }
.bar-fill.science { background: #9c6cff; }
.bar-value { width: 50px; text-align: right; font-size: 13px; color: var(--text-light); }
.line-chart { height: 160px; padding: 10px; background: var(--bg); border-radius: 8px; }
.line-chart svg { width: 100%; height: 100%; }

/* 记忆调度 */
.review-state-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 14px; }
.review-state-btn { padding: 12px; border-radius: 10px; background: var(--bg); text-align: center; cursor: pointer; border: 2px solid transparent; }
.review-state-btn:hover { border-color: var(--primary); }
.review-state-btn .em { font-size: 24px; }
.review-state-btn .t { font-weight: 600; margin-top: 4px; }
.review-state-btn .d { font-size: 11px; color: var(--text-light); }
.review-state-btn.mastered { background: #d9f2e7; }
.review-state-btn.fuzzy { background: #fff0d9; }
.review-state-btn.forgot { background: #ffe2e5; }

/* Toast */
.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-100px); background: var(--text); color: white; padding: 10px 20px; border-radius: 8px; font-size: 14px; transition: transform 0.3s; z-index: 1000; box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* Empty */
.empty { text-align: center; padding: 40px 20px; color: var(--text-light); }
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }

/* Modal */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.modal { background: var(--card); border-radius: var(--radius); padding: 22px; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; }
.modal-title { font-size: 17px; font-weight: 600; margin-bottom: 10px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

@media (max-width: 720px) {
  .topbar { padding: 8px 10px; flex-wrap: wrap; }
  .brand { font-size: 16px; }
  .nav-item { padding: 5px 10px; font-size: 13px; }
  .user-area { font-size: 12px; }
  .container { padding: 12px; }
  .auth-card { padding: 22px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .hero { padding: 16px; }
  .hero h2 { font-size: 18px; }
  .q-card { padding: 14px; }
  .page-title { font-size: 19px; }
}