:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1f2430;
  --ink-2: #5b6472;
  --ink-3: #98a1b0;
  --line: #e6e9f2;
  --accent: #4f6bf0;
  --accent-soft: #eef1fe;
  --red: #e0524f;
  --orange: #e98a2b;
  --yellow: #d9a920;
  --green: #2faa6f;
  --purple: #8b5cf6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .04), 0 6px 20px rgba(20, 30, 60, .05);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
}

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

/* ===== 登录页 ===== */
.login-body {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(600px 300px at 15% 0%, #e7ecff 0%, transparent 60%),
    radial-gradient(500px 260px at 90% 100%, #eef6ff 0%, transparent 55%),
    var(--bg);
}

.login-card {
  width: 100%; max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 36px 32px 28px;
}

.login-brand { text-align: center; margin-bottom: 24px; }
.brand-mark {
  width: 52px; height: 52px; margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #5b7cfa, #7b5cf6);
  color: #fff; font-size: 24px; font-weight: 700;
  border-radius: 16px;
  box-shadow: 0 8px 18px rgba(91, 124, 250, .28);
}
.brand-mark.small { width: 26px; height: 26px; font-size: 14px; border-radius: 8px; margin: 0 8px 0 0; box-shadow: none; }
.login-brand h1 { font-size: 21px; letter-spacing: 1px; }
.login-brand p { color: var(--ink-3); font-size: 13px; margin-top: 4px; }

.login-form label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 14px; }
.login-form input {
  width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; background: #fafbfe;
}
.login-form input:focus { outline: none; border-color: var(--accent); background: #fff; }

.btn-primary {
  width: 100%; padding: 11px; margin-top: 6px;
  border: none; border-radius: 10px;
  background: var(--accent); color: #fff;
  font-size: 15px; font-weight: 600; letter-spacing: 6px; cursor: pointer;
  transition: filter .15s;
}
.btn-primary:hover { filter: brightness(1.08); }

.alert {
  background: #fdeeee; color: #b33633;
  border: 1px solid #f6d3d3; border-radius: 10px;
  padding: 9px 12px; font-size: 13px; margin-bottom: 14px;
}

.login-hint { text-align: center; color: var(--ink-3); font-size: 12px; margin-top: 18px; }

/* ===== 顶栏 ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; font-weight: 700; font-size: 16px; color: var(--ink); }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-name { font-size: 14px; color: var(--ink-2); }
.btn-ghost {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  padding: 6px 12px; border-radius: 9px; font-size: 13px; cursor: pointer;
}
.btn-ghost:hover { border-color: #cbd3e8; color: var(--ink); }

/* ===== 主体 ===== */
.container { max-width: 1080px; margin: 0 auto; padding: 26px 20px 60px; }

.hero {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 18px;
  flex-wrap: wrap;
}
.hero h2 { font-size: 24px; letter-spacing: .5px; }
.hero-sub { color: var(--ink-3); font-size: 15px; font-weight: 400; margin-left: 8px; }
.hero-meta { color: var(--ink-3); font-size: 13px; margin-top: 6px; }

.stats { display: flex; gap: 12px; flex-wrap: wrap; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 20px; min-width: 108px; text-align: center;
}
.stat b { display: block; font-size: 22px; color: var(--ink); }
.stat span { font-size: 12px; color: var(--ink-3); }
.stat-btn { cursor: pointer; transition: transform .12s, box-shadow .12s; }
.stat-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(79, 107, 240, .16); }
.stat-btn span { color: var(--accent); }

.card-section { margin-top: 30px; }
.section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 16px; margin-bottom: 14px;
}
.section-note { color: var(--ink-3); font-size: 12px; font-weight: 400; }
.section-note.rank { color: var(--accent); font-weight: 600; margin-left: 4px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.red { background: var(--red); }
.dot.orange { background: var(--orange); }
.dot.indigo { background: var(--accent); }
.dot.purple { background: var(--purple); }
.dot.gray { background: var(--ink-3); }
.dot.green { background: var(--green); }

.empty-card {
  background: var(--card); border: 1px dashed #c9d2e8; border-radius: var(--radius);
  padding: 60px 30px; text-align: center; color: var(--ink-2);
}
.empty-card h2 { font-size: 18px; margin-bottom: 8px; }

/* ===== K0 卡片 ===== */
.k0-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.k0-card {
  background: var(--card); border: 1px solid var(--line); border-top: 3px solid var(--red);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px;
}
.k0-head { display: flex; align-items: center; justify-content: space-between; }
.k0-head h4 { font-size: 16px; }
.k0-meta { color: var(--ink-3); font-size: 12px; margin: 4px 0 10px; }

.mastery-badge {
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  white-space: nowrap;
}
.badge-red { background: #fdecec; color: #c13d3a; }
.badge-orange { background: #fdf1e3; color: #c4711a; }
.badge-yellow { background: #faf6dd; color: #9c7c12; }
.badge-green { background: #e4f6ec; color: #1e8a58; }

.kp-row { border-top: 1px solid #f0f2f8; padding: 9px 0; }
.kp-top { display: flex; justify-content: space-between; font-size: 13px; }
.kp-name { font-weight: 600; }
.kp-m1 { color: var(--ink-2); }
.rl-bar {
  display: flex; height: 6px; border-radius: 3px; overflow: hidden;
  background: #f0f2f8; margin: 6px 0 4px;
}
.rl-fill { background: var(--red); }
.rl-hfill { background: var(--orange); }
.kp-concl { font-size: 12px; color: var(--ink-2); }

/* ===== 掌握程度条 ===== */
.mastery-list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 18px; }
.mastery-row { display: flex; align-items: center; gap: 12px; padding: 7px 0; }
.mastery-name { width: 150px; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.mastery-track { flex: 1; height: 10px; background: #eef0f7; border-radius: 5px; overflow: hidden; }
.mastery-fill { height: 100%; border-radius: 5px; transition: width .4s ease; }
.m-red { background: linear-gradient(90deg, #f2706b, #e0524f); }
.m-orange { background: linear-gradient(90deg, #f2b15f, #e98a2b); }
.m-yellow { background: linear-gradient(90deg, #e8cf5d, #d9a920); }
.m-green { background: linear-gradient(90deg, #5cc492, #2faa6f); }
.mastery-val { width: 52px; text-align: right; font-size: 13px; font-weight: 600; }
.mastery-n { width: 42px; text-align: right; font-size: 12px; color: var(--ink-3); }

/* ===== 列表 ===== */
.plain-list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px 18px; }
.plain-item { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 11px 0; border-bottom: 1px solid #f0f2f8; font-size: 14px; }
.plain-item:last-child { border-bottom: none; }
.plain-item.warn { border-left: 3px solid var(--purple); padding-left: 10px; }
.plain-sub { color: var(--ink-3); font-size: 12px; }
.plain-tags { color: var(--ink-2); font-size: 12px; }

/* ===== 考试选择与当次/近几次分析 ===== */
.exam-pick .section-title { flex-wrap: wrap; }
.exam-select {
  margin-left: auto; padding: 7px 12px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 13px; background: #fafbfe; max-width: 340px; color: var(--ink);
}
.exam-select:focus { outline: none; border-color: var(--accent); }

.paper-btn {
  margin-left: 6px; width: auto; padding: 7px 12px; margin-top: 0; letter-spacing: 0;
  font-size: 13px; border-radius: 9px; white-space: nowrap; background: var(--accent);
}
.paper-btn[hidden] { display: none; }

.ans-btn {
  margin-left: 6px; width: auto; padding: 7px 12px; margin-top: 0; letter-spacing: 0;
  font-size: 13px; border-radius: 9px; white-space: nowrap; background: var(--accent);
}
.ans-btn[hidden] { display: none; }

.teacher-title { font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 10px; }
.teacher-result .exam-table-wrap { margin-top: 10px; }
.teacher-result .sub-head { padding-top: 18px; }
.opt-correct { font-weight: 700; color: var(--green); }

.exam-table-wrap {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow-x: auto;
}
.sub-list { margin-top: 12px; }
.sub-head { font-size: 14px; padding: 12px 16px 4px; color: var(--ink-2); }
.exam-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 620px; }
.exam-table th {
  text-align: left; padding: 11px 16px; color: var(--ink-3); font-weight: 500;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.exam-table td { padding: 9px 16px; border-bottom: 1px solid #f0f2f8; vertical-align: middle; }
.exam-table tr:last-child td { border-bottom: none; }
.exam-table tr:hover td { background: #fafbfe; }
.exam-table .b-name { font-weight: 600; white-space: nowrap; }
.rate-cell { display: flex; align-items: center; gap: 8px; min-width: 140px; }
.rate-val { width: 38px; text-align: right; font-weight: 600; }
.type-cell { min-width: 230px; }
.type-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: #f0f2f8; margin-bottom: 4px; }
.type-seg { height: 100%; }
.type-labels { font-size: 11px; color: var(--ink-2); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.lg.red { background: var(--red); }
.lg.orange { background: var(--orange); }
.lg.purple { background: var(--purple); }
.lg.gray { background: var(--ink-3); }
.legend-tip { margin-left: auto; color: var(--ink-3); }

/* ===== 教师页 ===== */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: #eef1fe; color: #4157c8; }
.tag-hot { background: #fdecec; color: #c13d3a; }
.tag-k0 { background: #fdecec; color: #c13d3a; }
.tag-gray { background: #eef0f5; color: var(--ink-2); }
.type-tag { background: #f0f2f8; color: var(--ink-2); }

.filter-input {
  margin-left: auto; padding: 6px 12px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 13px; background: #fafbfe; width: 180px;
}
.filter-input:focus { outline: none; border-color: var(--accent); }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stu-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stu-table th {
  text-align: left; padding: 12px 16px; color: var(--ink-3); font-weight: 500;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.stu-table td { padding: 11px 16px; border-bottom: 1px solid #f0f2f8; }
.stu-table tr:last-child td { border-bottom: none; }
.stu-table tr:hover td { background: #fafbfe; }
.k0-cell { max-width: 260px; }
.k0-cell .tag { margin: 2px 3px 2px 0; display: inline-block; }
.btn-link { font-size: 13px; font-weight: 600; }
.muted { color: var(--ink-3); }

/* ===== 修改密码对话框 ===== */
.pwd-dialog { border: none; border-radius: 16px; padding: 0; box-shadow: var(--shadow); }
.pwd-dialog::backdrop { background: rgba(30, 40, 70, .35); backdrop-filter: blur(2px); }
.pwd-box { padding: 26px 28px; width: 320px; }
.pwd-box h3 { font-size: 16px; margin-bottom: 14px; }
.pwd-box label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 12px; }
.pwd-box input { width: 100%; margin-top: 5px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; }
.pwd-box input:focus { outline: none; border-color: var(--accent); }
.pwd-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.pwd-actions .btn-primary { width: auto; padding: 8px 18px; letter-spacing: 2px; }
.pwd-msg { margin-top: 10px; font-size: 13px; }
.pwd-msg.ok { color: var(--green); }
.pwd-msg.err { color: var(--red); }

/* ===== 错题再练 ===== */
.wrong-dialog {
  border: none; border-radius: 18px; padding: 0; box-shadow: var(--shadow);
  width: min(760px, 94vw); max-height: 86vh;
}
.wrong-dialog::backdrop { background: rgba(30, 40, 70, .42); backdrop-filter: blur(3px); }
.wrong-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 24px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: #fff; border-radius: 18px 18px 0 0;
  cursor: grab; user-select: none;
}
.wrong-head h3 { font-size: 17px; }
.wrong-count { color: var(--ink-3); font-size: 13px; }
.wrong-actions { margin-left: auto; display: flex; gap: 8px; }
.wrong-list { padding: 18px 24px 26px; overflow-y: auto; max-height: calc(86vh - 70px); }
.wrong-card {
  border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px;
  margin-bottom: 14px; background: #fcfdff;
}
.wrong-meta { font-size: 12px; color: var(--ink-2); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.q-stem { font-size: 14px; line-height: 1.75; white-space: pre-wrap; }
.q-img { max-width: 100%; margin-top: 10px; border-radius: 8px; }
.q-opts { margin-top: 10px; }
.q-opt { font-size: 14px; padding: 5px 0; color: var(--ink); }
.q-ans-btn { margin-top: 12px; }
.q-answer { margin-top: 12px; padding: 12px 14px; background: #eef6f0; border: 1px solid #d5ead9; border-radius: 10px; }
.q-ans-text { font-size: 14px; color: #1e7d4b; }
.q-analysis { font-size: 13px; color: var(--ink-2); margin-top: 6px; line-height: 1.7; white-space: pre-wrap; }

/* ===== 错题再练 / 同知识块再练 ===== */
.q-retry-btns { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.q-redo-btn { padding: 7px 14px; font-size: 13px; border-radius: 8px; }
.q-similar-btn { padding: 7px 14px; font-size: 13px; border-radius: 8px; }
.q-retry-inline { gap: 6px; margin-top: 4px; }
.q-retry-inline .q-redo-btn, .q-retry-inline .q-similar-btn { padding: 4px 10px; font-size: 12px; white-space: nowrap; }
.redo-dialog { width: min(680px, 94vw); }
.redo-q { padding: 4px 0; }
.redo-opts .q-opt {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
  margin-top: 8px; cursor: pointer; transition: all .15s ease; background: #fff;
}
.redo-opts .q-opt:hover { border-color: var(--accent); background: var(--accent-soft); }
.redo-opt.opt-answer { border-color: #2e9e5b; background: #eef7f0; font-weight: 600; }
.redo-opt.opt-picked-correct { border-color: #2e9e5b; background: #eef7f0; box-shadow: 0 0 0 1px #2e9e5b; }
.redo-opt.opt-picked-wrong { border-color: #e06c5e; background: #fdeeee; box-shadow: 0 0 0 1px #e06c5e; }
.redo-input {
  width: 100%; min-height: 70px; margin-top: 10px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 10px; font-size: 14px; line-height: 1.6;
  box-sizing: border-box; resize: vertical; font-family: inherit;
}
.redo-feedback { margin-top: 10px; }
.redo-result { padding: 10px 14px; border-radius: 10px; font-size: 14px; }
.redo-correct { background: #eef7f0; border: 1px solid #cfe9d6; color: #1e7d4b; }
.redo-wrong { background: #fdeeee; border: 1px solid #f3cfca; color: #b24437; }
.redo-note { background: #f2f5ff; border: 1px solid #d6e0ff; color: var(--accent); }
.redo-dialog .wrong-list { max-height: calc(86vh - 70px); }
.md-table { border-collapse: collapse; margin: 10px 0; font-size: 13px; line-height: 1.5; }
.md-table th, .md-table td { border: 1px solid var(--line); padding: 5px 12px; text-align: center; }
.md-table th { background: var(--accent-soft); font-weight: 600; }
.md-table td { background: #fff; }

/* ===== 知识练习入口 ===== */
.practice-btn { font-size: 12px; padding: 4px 10px; border-radius: 8px; }
.practice-mini {
  border: none; background: #eef1fe; color: var(--accent);
  font-size: 12px; padding: 2px 8px; border-radius: 7px; cursor: pointer; margin-left: auto;
}
.practice-mini:hover { background: #dfe5fd; }

@media (max-width: 640px) {
  .hero { flex-direction: column; align-items: flex-start; }
  .mastery-name { width: 100px; }
  .k0-grid { grid-template-columns: 1fr; }
}

/* ===== 试卷预览（整卷页面图片 · 满宽上下滚动） ===== */
.paper-dialog {
  border: none; max-width: 860px; width: min(92vw, 860px); height: 88vh;
  border-radius: 14px; padding: 0; box-shadow: var(--shadow);
  overflow: hidden; display: flex; flex-direction: column;
}
.paper-dialog[open] { display: flex; }
.paper-dialog::backdrop { background: rgba(15, 25, 45, .55); }
.paper-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  border-bottom: 1px solid var(--line); background: #fff; flex: 0 0 auto;
}
.paper-title { font-size: 15px; font-weight: 600; color: var(--ink); margin: 0; margin-right: auto; }
.paper-actions { display: flex; align-items: center; gap: 6px; }
.paper-body { flex: 1 1 auto; min-height: 0; overflow: auto; background: #e8eaef; }
.paper-scroll { min-height: 100%; display: block; }
.paper-pages { padding: 10px; display: block; }
.paper-page-img {
  display: block; width: 100%; height: auto; margin: 0 auto 10px;
  box-shadow: 0 1px 6px rgba(0,0,0,.3); border-radius: 3px; background: #fff;
}
.paper-loading { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  color: #fff; font-size: 14px; background: rgba(0,0,0,.55); padding: 8px 16px; border-radius: 8px; }
.paper-loading[hidden] { display: none; }

/* ===== 作答卷预览（PDF.js，含缩放/旋转） ===== */
.ans-dialog[open] {
  width: min(94vw, 1200px);
  max-width: none;
  height: 92vh;
  max-height: none;
  padding: 12px 14px 16px;
  border: none;
  border-radius: 14px;
  background: #f3f5fb;
  box-shadow: 0 18px 60px rgba(20,40,70,.35);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ans-dialog::backdrop { background: rgba(15,25,45,.55); }
.ans-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ans-title { font-size: 15px; font-weight: 600; color: var(--ink); margin: 0; margin-right: auto; }
.ans-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ans-body {
  flex: 1; min-height: 0; overflow: hidden;
  background: #2b2f38; border-radius: 10px; position: relative;
}
.ans-scroll {
  position: absolute; inset: 0; overflow: auto;
  display: flex; justify-content: center;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  overscroll-behavior: contain;
}
.ans-rot { display: inline-block; width: max-content; }
.ans-pages { padding: 14px 8px; }
.ans-page {
  background: #fff; box-shadow: 0 4px 18px rgba(0,0,0,.35);
  margin-bottom: 14px; overflow: hidden;
}
.ans-page canvas { display: block; }
.ans-loading {
  position: absolute; inset: 0; z-index: 6;
  display: flex; align-items: center; justify-content: center;
  background: rgba(43,47,56,.72); color: #fff; font-size: 14px;
}
.ans-loading[hidden] { display: none; }
.ans-zoom-lbl {
  min-width: 44px; text-align: center; font-size: 12px; font-weight: 600; color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.ans-divider { width: 1px; height: 18px; background: #d5daea; margin: 0 4px; }

/* ===== ICP 备案页脚 ===== */
.icp-footer {
  margin-top: 32px; padding: 14px 0 18px;
  text-align: center; font-size: 12px; color: #9aa3b5;
}
.login-body .icp-footer { margin-top: 20px; }
.icp-footer a { color: #9aa3b5; text-decoration: none; }
.icp-footer a:hover { color: #5b6478; text-decoration: underline; }
