:root {
  --bg1: #0f2027;
  --bg2: #203a43;
  --bg3: #2c5364;
  --green: #34d399;
  --green-d: #059669;
  --purple: #a78bfa;
  --purple-d: #7c3aed;
  --yellow: #fbbf24;
  --red: #f87171;
  --red-d: #dc2626;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --soft: #f1f5f9;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0,0,0,.18);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, var(--bg1), var(--bg2), var(--bg3));
  background-attachment: fixed;
  min-height: 100vh;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; color: #fff;
  backdrop-filter: blur(6px);
  background: rgba(255,255,255,.06);
  border-bottom: 1px solid rgba(255,255,255,.12);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing:.3px; }
.brand .logo { font-size: 26px; }
.topbar .right { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.student-chip {
  background: rgba(255,255,255,.14); padding: 6px 12px; border-radius: 999px;
  display: flex; align-items: center; gap: 8px; cursor: pointer;
}
.student-chip:hover { background: rgba(255,255,255,.22); }
.link-btn {
  color: #fff; text-decoration: none; opacity: .85; font-size: 13px;
  border: 1px solid rgba(255,255,255,.25); padding: 6px 12px; border-radius: 999px;
}
.link-btn:hover { opacity: 1; background: rgba(255,255,255,.12); }

/* ---------- layout ---------- */
.wrap { max-width: 980px; margin: 0 auto; padding: 26px 18px 80px; }
.screen { display: none; animation: fade .35s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px);} to {opacity:1; transform:none;} }
h2.section { color:#fff; font-size: 24px; margin: 6px 0 18px; }
.sub { color: rgba(255,255,255,.7); margin: -12px 0 20px; font-size: 14px; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 720px){ .grid2, .grid3 { grid-template-columns: 1fr; } }

/* ---------- theme chooser ---------- */
.theme-card {
  position: relative; overflow: hidden; cursor: pointer; color:#fff;
  border-radius: var(--radius); padding: 26px; min-height: 180px;
  display: flex; flex-direction: column; justify-content: space-between;
  transition: transform .15s ease, box-shadow .15s ease;
}
.theme-card:hover { transform: translateY(-4px); box-shadow: 0 16px 40px rgba(0,0,0,.3); }
.theme-al { background: linear-gradient(135deg, #059669, #10b981); }
.theme-nsaa { background: linear-gradient(135deg, #7c3aed, #6366f1); }
.theme-card .big { font-size: 40px; }
.theme-card h3 { margin: 8px 0 4px; font-size: 22px; }
.theme-card p { margin: 0; opacity:.9; font-size: 14px; }

/* ---------- mode cards ---------- */
.mode-card {
  cursor: pointer; border-radius: 14px; padding: 18px; background: var(--soft);
  border: 2px solid transparent; transition: all .15s ease; text-align: left;
}
.mode-card:hover { border-color: var(--purple); transform: translateY(-3px); }
.mode-card .ico { font-size: 28px; }
.mode-card h4 { margin: 8px 0 4px; font-size: 16px; }
.mode-card p { margin: 0; font-size: 13px; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  border: none; border-radius: 12px; padding: 12px 18px; font-size: 15px;
  font-weight: 700; cursor: pointer; transition: transform .12s ease, filter .12s ease;
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--green); color:#063; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-purple { background: var(--purple); color:#fff; }
.btn-purple:hover { filter: brightness(1.05); }
.btn-ghost { background: var(--soft); color: var(--ink); }
.btn-ghost:hover { background:#e2e8f0; }
.btn-block { width: 100%; }
.btn:disabled { opacity:.5; cursor: not-allowed; }

/* ---------- form controls ---------- */
label.field { display:block; font-size: 13px; font-weight:700; color: var(--muted); margin: 14px 0 6px; }
select, input[type=number], input[type=text] {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid #cbd5e1;
  font-size: 15px; background:#fff; color: var(--ink);
}
.range-row { display:flex; align-items:center; gap: 12px; }
input[type=range] { flex:1; accent-color: var(--purple-d); }
.range-val { font-weight:800; min-width: 54px; text-align:right; color: var(--purple-d); }
.toggle { display:flex; align-items:center; gap:10px; margin-top:14px; }
.toggle input { width:18px; height:18px; accent-color: var(--purple-d); }

/* ---------- quiz ---------- */
.quiz-head { display:flex; align-items:center; justify-content: space-between; gap:12px; color:#fff; margin-bottom: 14px; flex-wrap: wrap;}
.pill { background: rgba(255,255,255,.14); padding:5px 12px; border-radius:999px; font-size:13px; font-weight:700; }
.pill.timer.warn { background: var(--red); color:#fff; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:.55;} }
.progress-track { height: 8px; background: rgba(255,255,255,.18); border-radius:999px; overflow:hidden; margin-bottom: 14px; }
.progress-fill { height:100%; background: linear-gradient(90deg, var(--green), var(--yellow)); width:0%; transition: width .3s ease; }

.qmeta { display:flex; gap:10px; align-items:center; margin-bottom:10px; flex-wrap:wrap; }
.tag { font-size:12px; font-weight:700; padding:4px 10px; border-radius:999px; background: var(--soft); color: var(--purple-d); }
.qimg-wrap { background:#fff; border-radius:14px; padding:14px; display:flex; justify-content:center; align-items:flex-start; box-shadow: var(--shadow); }
.qimg { max-width:100%; max-height: 460px; border-radius:8px; }
.qimg-fallback { padding: 24px; color: var(--muted); text-align:center; font-size:14px; }

.options { display:grid; grid-template-columns: 1fr 1fr; gap:12px; margin-top:16px; }
@media (max-width:560px){ .options { grid-template-columns: 1fr; } }
.opt {
  display:flex; align-items:center; gap:12px; padding:14px 16px; border-radius:12px;
  background:#fff; border:2px solid #e2e8f0; cursor:pointer; font-size:15px; transition: all .12s ease;
  text-align:left;
}
.opt:hover { border-color: var(--purple); }
.opt .ltr { font-weight:800; width:30px; height:30px; flex:0 0 30px; border-radius:50%; background: var(--soft); display:flex; align-items:center; justify-content:center; }
.opt.correct { border-color: var(--green-d); background:#ecfdf5; }
.opt.correct .ltr { background: var(--green); color:#fff; }
.opt.wrong { border-color: var(--red-d); background:#fef2f2; }
.opt.wrong .ltr { background: var(--red); color:#fff; }
.opt.dim { opacity:.5; pointer-events:none; }
.opt.selected { border-color: var(--purple-d); background:#f5f3ff; box-shadow:0 0 0 2px rgba(124,58,237,.25) inset; }
.opt.selected .ltr { background: var(--purple-d); color:#fff; }

.feedback { margin-top:14px; padding:14px 16px; border-radius:12px; font-weight:700; display:none; }
.feedback.show { display:block; animation: fade .25s ease; }
.feedback.ok { background:#ecfdf5; color: var(--green-d); }
.feedback.no { background:#fef2f2; color: var(--red-d); }

.qfooter { display:flex; align-items:center; justify-content: space-between; margin-top:16px; gap:12px; }
.star-btn { background:none; border:2px solid #e2e8f0; border-radius:10px; padding:8px 12px; cursor:pointer; font-size:14px; font-weight:700; color: var(--muted); }
.star-btn.on { border-color: var(--yellow); background:#fffbeb; color:#b45309; }

/* ---------- results ---------- */
.score-ring { width: 150px; height:150px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:30px; font-weight:800; margin: 0 auto 10px; color:#fff; }
.stat-row { display:flex; gap:14px; justify-content:center; flex-wrap:wrap; margin: 18px 0; }
.stat { background: var(--soft); border-radius:14px; padding:14px 20px; text-align:center; min-width:110px; }
.stat .n { font-size:22px; font-weight:800; }
.stat .l { font-size:12px; color: var(--muted); }
.topic-bars { margin-top:16px; }
.topic-bar { display:flex; align-items:center; gap:10px; margin:8px 0; }
.topic-bar .name { width: 200px; font-size:13px; color: var(--ink); flex:0 0 200px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.topic-bar .track { flex:1; height:14px; background:#e2e8f0; border-radius:999px; overflow:hidden; }
.topic-bar .fill { height:100%; background: linear-gradient(90deg,var(--purple),var(--green)); }
.topic-bar .pct { width:48px; text-align:right; font-size:13px; font-weight:700; }

/* ---------- stats page ---------- */
.hero-stats { display:grid; grid-template-columns: repeat(4,1fr); gap:14px; }
@media (max-width:720px){ .hero-stats{ grid-template-columns: repeat(2,1fr);} }
.hero { background: linear-gradient(135deg, var(--purple-d), var(--green-d)); color:#fff; border-radius: var(--radius); padding:20px; text-align:center; }
.hero .n { font-size:30px; font-weight:900; }
.hero .l { font-size:13px; opacity:.9; }

/* ---------- teacher table ---------- */
.tbl { width:100%; border-collapse: collapse; font-size:14px; }
.tbl th, .tbl td { text-align:left; padding:10px 12px; border-bottom:1px solid #eef2f7; }
.tbl th { color: var(--muted); font-size:12px; text-transform: uppercase; letter-spacing:.4px; }
.tbl tr:hover td { background:#f8fafc; }
.acc-good { color: var(--green-d); font-weight:800; }
.acc-mid { color: var(--yellow); font-weight:800; }
.acc-bad { color: var(--red-d); font-weight:800; }
.weak-tags { display:flex; flex-wrap:wrap; gap:5px; }
.weak-tag { font-size:11px; background:#fef2f2; color: var(--red-d); padding:3px 8px; border-radius:999px; }
.date-pill { font-size:13px; padding:6px 12px; border-radius:999px; border:1px solid #cbd5e1; background:#fff; cursor:pointer; }
.date-pill.sel { background: var(--purple); color:#fff; border-color: var(--purple); }
.empty { text-align:center; color: var(--muted); padding:40px; }
.backlink { display:inline-block; margin-bottom:14px; color:#fff; text-decoration:none; opacity:.85; }
.backlink:hover { opacity:1; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset:0; background: rgba(15,23,42,.55); display:none; align-items:center; justify-content:center; z-index:100; padding:20px; }
.modal-bg.show { display:flex; }
.modal { background:#fff; border-radius: var(--radius); padding:24px; width:100%; max-width:360px; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 12px; }
.modal .hint { font-size:13px; color: var(--muted); margin-bottom:14px; }
.toast { position: fixed; bottom: 24px; left:50%; transform: translateX(-50%); background: var(--ink); color:#fff; padding:10px 18px; border-radius:999px; font-size:14px; opacity:0; transition: opacity .3s ease; z-index:200; pointer-events:none; }
.toast.show { opacity:1; }

/* ---------- results review (错题解析 / 知识点总结) ---------- */
.review-title{ font-size:16px; font-weight:800; color:var(--ink); margin-bottom:12px; display:flex; align-items:center; gap:8px; }
.review-count{ font-size:12px; font-weight:600; color:var(--muted); }
.review-toggle-row{ display:flex; gap:8px; margin-bottom:14px; }
.chip-btn{ border:1.5px solid #e2e8f0; background:#fff; color:var(--muted); border-radius:999px;
  padding:6px 14px; font-size:13px; font-weight:700; cursor:pointer; transition:all .15s; }
.chip-btn.active{ background:var(--purple-d); border-color:var(--purple-d); color:#fff; }
.review-list{ display:flex; flex-direction:column; gap:12px; }
.rev-item{ border:1px solid #eef2f7; border-radius:14px; padding:12px; background:#fafbfd; }
.rev-item.ok{ border-left:5px solid var(--green-d); }
.rev-item.no{ border-left:5px solid var(--red-d); }
.rev-item.skip{ border-left:5px solid #94a3b8; }
.rev-head{ display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin-bottom:8px; }
.rev-q{ font-weight:800; color:var(--ink); font-size:14px; }
.rev-badge{ font-size:12px; font-weight:700; padding:2px 9px; border-radius:999px; }
.rev-badge.ok{ background:#dcfce7; color:#047857; }
.rev-badge.no{ background:#fee2e2; color:#b91c1c; }
.rev-badge.skip{ background:#e2e8f0; color:#475569; }
.rev-badge.topic{ background:#ede9fe; color:#6d28d9; }
.rev-badge.src{ background:#f1f5f9; color:#64748b; }
.rev-ans{ font-size:13px; color:var(--ink); margin-bottom:8px; }
.rev-ans b.correct{ color:var(--green-d); }
.rev-ans b.wrong{ color:var(--red-d); }
.rev-img{ width:100%; max-width:520px; border-radius:10px; border:1px solid #e5e7eb; display:block; }
.kp-row{ display:flex; align-items:center; gap:10px; margin:8px 0; }
.kp-name{ flex:0 0 46%; font-weight:700; font-size:13px; color:var(--ink); }
.kp-track{ flex:1; height:12px; border-radius:999px; background:#eef2f7; overflow:hidden; }
.kp-fill{ height:100%; border-radius:999px; background:linear-gradient(90deg,var(--red-d),var(--yellow)); }
.kp-count{ flex:0 0 auto; font-size:12px; font-weight:800; color:var(--red-d); }
.kp-note{ font-size:13px; color:var(--muted); margin-top:10px; line-height:1.5; }
