/* ============ 基础 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --green: #16a34a;
  --green-bg: #f0fdf4;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --text: #1e293b;
  --text-2: #64748b;
  --text-3: #94a3b8;
  --border: #e2e8f0;
  --bg: #f6f7fb;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .10);
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }

/* ============ 顶栏 ============ */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: .5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo::before {
  content: "G";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
}
.nav { display: flex; gap: 6px; }
.nav a {
  padding: 7px 14px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 15px;
  transition: all .15s;
}
.nav a:hover { background: var(--primary-light); color: var(--primary); }
.nav a.active { background: var(--primary); color: #fff; }

main { flex: 1; width: 100%; }

.container { max-width: 1120px; margin: 0 auto; padding: 28px 20px 60px; }

.footer {
  text-align: center;
  padding: 22px;
  color: var(--text-3);
  font-size: 13px;
  border-top: 1px solid var(--border);
}

/* ============ 通用组件 ============ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 22px;
  border-radius: 10px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline {
  background: #fff;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: #15803d; }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-gray { background: #f1f5f9; color: var(--text-2); }

.page-title { font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.page-sub { color: var(--text-2); font-size: 15px; margin-bottom: 24px; }

.grade-tabs { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.grade-tabs a {
  padding: 8px 20px;
  border-radius: 10px;
  background: #fff;
  color: var(--text-2);
  font-weight: 600;
  border: 1px solid var(--border);
  transition: all .15s;
}
.grade-tabs a:hover { border-color: var(--primary); color: var(--primary); }
.grade-tabs a.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ============ 首页 ============ */
.hero {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  border-radius: 20px;
  color: #fff;
  padding: 44px 40px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-lg);
}
.hero h1 { font-size: 30px; margin-bottom: 10px; }
.hero p { opacity: .92; font-size: 15.5px; max-width: 640px; }
.hero .hero-actions { margin-top: 22px; display: flex; gap: 12px; flex-wrap: wrap; }
.hero .btn { background: #fff; color: var(--primary); }
.hero .btn:hover { background: #eef2ff; }

.grade-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grade-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
  transition: all .2s;
  border-top: 4px solid var(--primary);
}
.grade-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-3px); }
.grade-card h3 { font-size: 21px; margin-bottom: 4px; }
.grade-card .desc { color: var(--text-2); font-size: 13.5px; margin-bottom: 16px; min-height: 40px; }

.stat-row { display: flex; gap: 18px; margin-bottom: 18px; }
.stat { flex: 1; }
.stat .num { font-size: 22px; font-weight: 700; }
.stat .label { font-size: 12px; color: var(--text-3); }
.progress-track {
  height: 8px;
  background: #eef2f7;
  border-radius: 4px;
  overflow: hidden;
  margin: 4px 0 14px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #7c3aed);
  border-radius: 4px;
  transition: width .4s;
}
.grade-card .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.grade-card .actions a {
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
  transition: all .15s;
}
.grade-card .actions a:hover { background: var(--primary); color: #fff; }

.wrong-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 1.5px dashed var(--red);
  border-radius: var(--radius);
  padding: 18px 24px;
  margin-top: 24px;
}
.wrong-entry .info { display: flex; align-items: center; gap: 14px; }
.wrong-entry .icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--red-bg);
  color: var(--red);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700;
}
.wrong-entry h4 { font-size: 16px; }
.wrong-entry p { font-size: 13px; color: var(--text-2); }

/* ============ 知识点页 ============ */
.topics-layout { display: grid; grid-template-columns: 250px 1fr; gap: 22px; align-items: start; }
.topic-list {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
.topic-list a {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 13.8px;
  transition: all .12s;
  margin-bottom: 2px;
}
.topic-list a:hover { background: var(--primary-light); color: var(--primary); }
.topic-list a.active { background: var(--primary); color: #fff; font-weight: 600; }

.topic-content {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 40px;
  min-height: 500px;
}
.topic-content h2 { font-size: 24px; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 2px solid var(--primary-light); }

.topic-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 22px;
  font-size: 14.5px;
  display: block;
  overflow-x: auto;
}
.topic-content th, .topic-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}
.topic-content th { background: var(--primary-light); color: var(--primary-dark); white-space: nowrap; }
.topic-content tr:nth-child(even) td { background: #fafbfe; }
.topic-content h3 { font-size: 18px; margin: 24px 0 10px; color: var(--primary-dark); }
.topic-content h4 { font-size: 15.5px; margin: 18px 0 8px; }
.topic-content p { margin: 8px 0; }
.topic-content ul, .topic-content ol { padding-left: 24px; margin: 8px 0; }
.topic-content li { margin: 4px 0; }
.topic-content strong { color: #0f172a; }
.topic-content code {
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: .92em;
}
.topic-content hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.topic-nav { display: flex; justify-content: space-between; margin-top: 28px; gap: 10px; }
.topic-nav a {
  padding: 8px 18px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
}
.topic-nav a:hover { background: var(--primary-light); color: var(--primary); }

/* ============ 板块选择页 ============ */
.section-list { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.section-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: all .2s;
}
.section-card:hover { box-shadow: var(--shadow-lg); }
.section-card .s-info h4 { font-size: 17px; margin-bottom: 3px; }
.section-card .s-info p { font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.section-card .s-stats { display: flex; gap: 12px; font-size: 12.5px; color: var(--text-2); }
.section-card .s-stats b { color: var(--text); }

.mistake-banner {
  background: linear-gradient(135deg, #dc2626 0%, #ea580c 100%);
  border-radius: var(--radius);
  color: #fff;
  padding: 26px 28px;
  margin-bottom: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-lg);
}
.mistake-banner h3 { font-size: 20px; margin-bottom: 4px; }
.mistake-banner p { opacity: .92; font-size: 13.5px; }
.mistake-banner .btn { background: #fff; color: var(--red); white-space: nowrap; }
.mistake-banner .btn:hover { background: #fff5f5; }

/* ============ 做题会话 ============ */
.session-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 12px;
  flex-wrap: wrap;
}
.session-head h3 { font-size: 19px; }
.session-head .quit { font-size: 14px; color: var(--text-3); }
.session-head .quit:hover { color: var(--red); }
.session-progress { margin-bottom: 22px; }
.session-progress .meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 6px;
}

.q-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 32px;
}
.q-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 10px; flex-wrap: wrap; }
.q-num { font-size: 13px; color: var(--text-3); }
.q-stem {
  font-size: 17.5px;
  line-height: 1.9;
  margin-bottom: 22px;
  white-space: pre-wrap;
}
.q-stem .blank, .q-target .blank {
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 1px;
}
.q-target {
  background: var(--bg);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 20px;
  font-size: 16px;
  white-space: pre-wrap;
  border-left: 4px solid var(--primary);
}

.options { display: grid; gap: 10px; }
.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all .12s;
  background: #fff;
  font-size: 15.5px;
  text-align: left;
  width: 100%;
  font-family: inherit;
  line-height: 1.6;
}
.option:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-light); }
.option .letter {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: #f1f5f9;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-2);
}
.option.correct {
  border-color: var(--green);
  background: var(--green-bg);
}
.option.correct .letter { background: var(--green); color: #fff; }
.option.wrong {
  border-color: var(--red);
  background: var(--red-bg);
}
.option.wrong .letter { background: var(--red); color: #fff; }
.option.dim { opacity: .55; }

.fill-input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border .15s;
  margin-bottom: 14px;
}
.fill-input:focus { border-color: var(--primary); }

.feedback {
  border-radius: 12px;
  padding: 16px 20px;
  margin-top: 20px;
  animation: fadeUp .25s ease;
}
.feedback.right { background: var(--green-bg); border: 1px solid #bbf7d0; }
.feedback.wrong-fb { background: var(--red-bg); border: 1px solid #fecaca; }
.feedback .fb-title { font-weight: 700; font-size: 15.5px; margin-bottom: 6px; }
.feedback.right .fb-title { color: var(--green); }
.feedback.wrong-fb .fb-title { color: var(--red); }
.feedback .fb-answer { font-size: 16px; margin-bottom: 6px; }
.feedback .fb-answer strong { font-size: 17px; }

.explain-box {
  background: var(--amber-bg);
  border: 1px solid #fde68a;
  border-radius: 12px;
  padding: 16px 20px;
  margin-top: 12px;
  font-size: 14.5px;
}
.explain-box .ex-title { font-weight: 700; color: var(--amber); margin-bottom: 6px; }
.explain-box .row { margin: 5px 0; }
.explain-box .row b { color: #92400e; }

.self-mark {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.self-mark .tip { font-size: 14px; color: var(--text-2); }
.self-mark .btns { display: flex; gap: 10px; }

.session-actions { display: flex; justify-content: flex-end; margin-top: 22px; gap: 10px; }

/* 做题小结 */
.summary-card { text-align: center; padding: 44px 32px; }
.score-ring {
  width: 150px; height: 150px;
  border-radius: 50%;
  margin: 0 auto 18px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border: 8px solid var(--primary-light);
}
.score-ring.good { border-color: #bbf7d0; }
.score-ring.mid { border-color: #fde68a; }
.score-ring.bad { border-color: #fecaca; }
.score-ring .score { font-size: 38px; font-weight: 800; color: var(--primary); line-height: 1.1; }
.score-ring .score-label { font-size: 13px; color: var(--text-3); }
.summary-stats { display: flex; justify-content: center; gap: 34px; margin: 20px 0 26px; }
.summary-stats .s { text-align: center; }
.summary-stats .s .n { font-size: 24px; font-weight: 700; }
.summary-stats .s .l { font-size: 12.5px; color: var(--text-3); }

/* ============ 错题本 ============ */
.wb-list { display: grid; gap: 14px; }
.wb-item {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 22px;
}
.wb-item .wi-head { display: flex; justify-content: space-between; margin-bottom: 8px; align-items: center; }
.wb-item .wi-stem { font-size: 15px; margin-bottom: 10px; white-space: pre-wrap; }
.wb-item details { margin-top: 8px; }
.wb-item summary {
  cursor: pointer;
  font-size: 13.5px;
  color: var(--primary);
  user-select: none;
  width: fit-content;
}
.wb-item .wi-detail { font-size: 14px; margin-top: 10px; padding: 12px 16px; background: var(--bg); border-radius: 10px; }
.wb-item .wi-detail .ans { color: var(--green); font-weight: 700; }
.wb-item .wi-detail .row { margin: 4px 0; }
.wb-item .wi-detail b { color: #92400e; }
.wb-remove {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-family: inherit;
}
.wb-remove:hover { color: var(--red); background: var(--red-bg); }

.empty-box {
  text-align: center;
  padding: 70px 20px;
  color: var(--text-3);
}
.empty-box .big { font-size: 46px; margin-bottom: 12px; }

/* ============ 动画 ============ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeUp .3s ease; }

/* ============ 响应式 ============ */
@media (max-width: 860px) {
  .grade-grid, .section-list { grid-template-columns: 1fr; }
  .topics-layout { grid-template-columns: 1fr; }
  .topic-list { position: static; max-height: none; }
  .hero { padding: 30px 24px; }
  .hero h1 { font-size: 24px; }
  .topic-content { padding: 24px 20px; }
  .q-card { padding: 22px 18px; }
  .container { padding: 20px 14px 40px; }
}
