:root {
  --blue: #1F4E79; --blue-l: #2d6da3;
  --bg: #f0f2f5; --card: #ffffff;
  --text: #26303a; --text-2: #6b7684;
  --green: #16a34a; --green-bg: #e8f7ee;
  --red: #dc2626; --red-bg: #fdecec;
  --gold: #f59e0b; --gold-bg: #fef6e7;
  --line: #e2e6eb; --radius: 12px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
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: 15px;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ===== 网络状态点 ===== */
.net-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: #c33; vertical-align: middle; margin-right: 4px;
}
.net-dot.online { background: #22c55e; box-shadow: 0 0 4px #22c55e; }

/* ===== 登录页 ===== */
#view-login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #1F4E79 0%, #2d6da3 60%, #3b82c4 100%);
  padding: 20px;
}
.login-box {
  background: #fff; border-radius: 18px; padding: 32px 26px; width: 100%; max-width: 400px;
  box-shadow: 0 18px 50px rgba(0,0,0,.28); position: relative; text-align: center;
}
.login-box .logo { font-size: 44px; }
.login-box h1 { font-size: 22px; margin: 6px 0 2px; color: var(--blue); }
.login-box .sub { color: var(--text-2); font-size: 13px; margin-bottom: 14px; }
.login-box .net-dot { position: absolute; top: 14px; right: 14px; }
.login-h2 { font-size: 14px; color: var(--text-2); text-align: left; margin: 10px 0 8px; font-weight: 600; }
.user-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.user-card {
  border: 1.5px solid var(--line); border-radius: 12px; padding: 14px 6px;
  background: #fafbfc; display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: all .15s;
}
.user-card .avatar {
  width: 44px; height: 44px; border-radius: 50%; background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 19px; font-weight: 600;
}
.user-card .uname { font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card:active { transform: scale(.96); }
.user-card:hover { border-color: var(--blue-l); }
.new-user { display: flex; gap: 8px; margin-top: 14px; }
.new-user input {
  flex: 1; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px; outline: none;
}
.new-user input:focus { border-color: var(--blue-l); }
.new-user button, .btn-primary {
  background: var(--blue); color: #fff; border: none; border-radius: 10px;
  padding: 10px 16px; font-size: 14px; font-weight: 600;
}
.new-user button:active, .btn-primary:active { opacity: .85; }
.login-tip { margin-top: 12px; font-size: 12px; color: var(--text-2); }
.msg { min-height: 18px; font-size: 13px; color: var(--red); margin-top: 8px; }
.msg.ok { color: var(--green); }

/* ===== 主框架 ===== */
.topbar {
  position: sticky; top: 0; z-index: 20; height: 48px;
  background: var(--blue); color: #fff; display: flex; align-items: center;
  justify-content: space-between; padding: 0 12px;
}
.topbar-title { font-weight: 600; font-size: 16px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.topbar .net-dot { margin-right: 2px; }
.topbar-user { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-ghost {
  background: rgba(255,255,255,.15); color: #fff; border: none; border-radius: 8px;
  padding: 6px 10px; font-size: 13px;
}
.page:not(.topbar) .btn-ghost { background: #eef1f5; color: var(--text); }

.banner {
  background: var(--gold-bg); color: #92600a; font-size: 13px; padding: 7px 12px;
  border-bottom: 1px solid #f3dfae;
}
.page { max-width: 720px; margin: 0 auto; padding: 14px 14px 40px; }

/* ===== 模块列表 ===== */
.module-item {
  background: var(--card); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(20,40,70,.06);
}
.module-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.module-name { font-weight: 700; font-size: 16px; color: var(--blue); }
.module-stats { font-size: 12px; color: var(--text-2); margin-bottom: 10px; }
.module-stats b { color: var(--green); }
.module-bar { height: 6px; border-radius: 4px; background: #edf0f3; overflow: hidden; margin-bottom: 10px; }
.module-bar > div { height: 100%; background: linear-gradient(90deg, var(--blue-l), var(--green)); border-radius: 4px; }
.module-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-primary.small { padding: 8px 18px; font-size: 13px; }
.btn-outline {
  background: #fff; border: 1.5px solid var(--line); border-radius: 10px;
  padding: 8px 14px; font-size: 13px; color: var(--text-2);
}
.btn-outline:active { background: #f3f5f7; }
.btn-outline.warn { color: var(--red); border-color: #f2c7c7; }
.home-links { display: flex; gap: 10px; margin-top: 18px; }
.home-links .btn-outline { flex: 1; padding: 12px; }

/* ===== 刷题页 ===== */
.quiz-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13px; color: var(--text-2);
}
.quiz-module { font-weight: 700; color: var(--text); font-size: 15px; flex: 1; }
.progress-bar { height: 7px; background: #e5e9ee; border-radius: 5px; overflow: hidden; margin-bottom: 16px; }
#quiz-progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--blue-l), var(--green)); transition: width .25s; }

.q-card { background: var(--card); border-radius: var(--radius); padding: 18px 16px; box-shadow: 0 1px 4px rgba(20,40,70,.06); }
.q-meta { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; }
.q-type {
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 20px;
  background: #eaf1f8; color: var(--blue);
}
.q-type.multi { background: #f4ecfb; color: #7c3aed; }
.q-index { font-size: 12px; color: var(--text-2); }
.q-stem { font-size: 16px; line-height: 1.7; margin-bottom: 16px; white-space: pre-wrap; }

.opt {
  display: flex; gap: 10px; padding: 12px 12px; border: 1.5px solid var(--line);
  border-radius: 10px; margin-bottom: 10px; font-size: 15px; line-height: 1.55;
  background: #fafbfc; transition: border-color .12s;
}
.opt .letter {
  flex: none; width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid #c8d0d9;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: var(--text-2);
}
.opt.selected { border-color: var(--blue-l); background: #eaf2fa; }
.opt.selected .letter { border-color: var(--blue-l); background: var(--blue-l); color: #fff; }
.opt.correct { border-color: var(--green); background: var(--green-bg); }
.opt.correct .letter { border-color: var(--green); background: var(--green); color: #fff; }
.opt.wrong { border-color: var(--red); background: var(--red-bg); }
.opt.wrong .letter { border-color: var(--red); background: var(--red); color: #fff; }
.opt.dim { opacity: .55; }

.btn-submit {
  width: 100%; padding: 13px; font-size: 15px; font-weight: 600; border: none; border-radius: 10px;
  background: var(--blue); color: #fff; margin-top: 4px;
}
.btn-submit:disabled { background: #b7c3cf; cursor: not-allowed; }

.feedback { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 14px; }
.fb-line { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.fb-line.ok { color: var(--green); }
.fb-line.no { color: var(--red); }
.fb-answer { font-size: 14px; line-height: 1.7; margin-bottom: 6px; }
.fb-answer b { color: var(--green); }
.fb-analysis { font-size: 13.5px; color: var(--text-2); line-height: 1.7; background: #f6f8fa; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.fb-actions { display: flex; gap: 10px; }
.btn-mastered {
  flex: none; padding: 11px 16px; border-radius: 10px; border: 1.5px solid var(--gold);
  background: var(--gold-bg); color: #92600a; font-size: 14px; font-weight: 600;
}
.btn-next { flex: 1; }

.quiz-done { text-align: center; padding: 40px 10px; }
.quiz-done .big { font-size: 42px; margin-bottom: 8px; }
.quiz-done h3 { margin-bottom: 8px; }
.quiz-done p { color: var(--text-2); font-size: 14px; margin-bottom: 18px; }

/* ===== 导入页 / 管理页 ===== */
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.page-head h2 { font-size: 17px; color: var(--blue); flex: 1; }
.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: 0 1px 4px rgba(20,40,70,.06); margin-bottom: 14px; font-size: 14px;
}
.card p { line-height: 1.9; color: var(--text-2); }
.card p b, .card p code { color: var(--text); }
.import-preview { margin-top: 12px; max-height: 300px; overflow: auto; }
.import-preview table { width: 100%; border-collapse: collapse; font-size: 13px; }
.import-preview th, .import-preview td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.import-preview .tag-ok { color: var(--green); }
.import-preview .tag-dup { color: var(--text-2); }
.import-preview .tag-bad { color: var(--red); }
#import-file { margin: 6px 0; width: 100%; }

.manage-tip { font-size: 12.5px; color: var(--text-2); margin-bottom: 10px; }
.mg-row {
  display: flex; gap: 8px; align-items: center; background: var(--card); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 8px; font-size: 13.5px;
}
.mg-stem { flex: 1; line-height: 1.5; }
.mg-src { font-size: 11px; color: var(--text-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; flex: none; }
.mg-row select { border: 1.5px solid var(--line); border-radius: 8px; padding: 5px 6px; font-size: 12.5px; max-width: 130px; background: #fff; }

/* ===== 弹窗 / Toast ===== */
.modal { position: fixed; inset: 0; background: rgba(10,20,35,.45); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal-box { background: #fff; border-radius: 14px; width: 100%; max-width: 520px; max-height: 80vh; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 16px; color: var(--blue); }
.modal-head .btn-ghost { background: #eef1f5; color: var(--text); }
.modal-body { overflow: auto; padding: 10px 14px; }
.mq-item { padding: 10px 4px; border-bottom: 1px dashed var(--line); font-size: 13.5px; display: flex; gap: 10px; align-items: center; }
.mq-item .t { flex: 1; line-height: 1.5; }
.mq-item button { flex: none; }

.toast {
  position: fixed; left: 50%; bottom: 44px; transform: translateX(-50%);
  background: rgba(30,40,55,.92); color: #fff; padding: 10px 20px; border-radius: 22px;
  font-size: 13.5px; z-index: 99; max-width: 86vw; text-align: center;
}

@media (max-width: 420px) {
  .user-grid { grid-template-columns: repeat(2, 1fr); }
  .q-stem { font-size: 15px; }
}
