:root {
  --red: #c0392b;
  --red-dark: #96281b;
  --bg: #f5f2ec;
  --card: #ffffff;
  --text: #2c2c2c;
  --muted: #8a8a8a;
  --line: #e5e0d8;
  --green: #27ae60;
  --orange: #e67e22;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.container { max-width: 760px; margin: 0 auto; padding: 16px; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: var(--card); border-radius: 12px; padding: 36px 32px;
  width: 100%; max-width: 380px; box-shadow: 0 8px 30px rgba(0,0,0,.08);
}
.login-card h1 { text-align: center; font-size: 22px; margin-bottom: 6px; color: var(--red); }
.login-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }

input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 15px; background: #fff; color: var(--text); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(192,57,43,.25); border-color: var(--red); }

.btn {
  display: inline-block; border: none; border-radius: 8px; padding: 10px 18px;
  font-size: 15px; cursor: pointer; background: var(--red); color: #fff;
  transition: background .15s; text-align: center;
}
.btn:hover { background: var(--red-dark); }
.btn:disabled { background: #ccc; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--red); border: 1px solid var(--red); }
.btn.ghost:hover { background: #fdf0ee; }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn.gray { background: #9aa0a6; }
.btn.gray:hover { background: #7d8389; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--red); color: #fff;
  position: sticky; top: 0; z-index: 10;
}
.topbar .title { font-size: 17px; font-weight: 600; }
.topbar .user { font-size: 13px; display: flex; gap: 10px; align-items: center; }
.topbar a { color: #ffe9e5; text-decoration: none; cursor: pointer; }
.topbar a:hover { text-decoration: underline; }

/* ---------- 主页 ---------- */
.home-header { padding: 20px 4px 6px; }
.home-header h2 { font-size: 20px; }
.home-header p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat-row { display: flex; gap: 10px; margin: 14px 0; }
.stat {
  flex: 1; background: var(--card); border-radius: 10px; padding: 12px;
  text-align: center; border: 1px solid var(--line);
}
.stat .num { font-size: 22px; font-weight: 700; color: var(--red); }
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }

.menu { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px; }
.menu-item {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px 14px; cursor: pointer; transition: box-shadow .15s, transform .1s;
}
.menu-item:hover { box-shadow: 0 4px 16px rgba(0,0,0,.07); }
.menu-item:active { transform: scale(.98); }
.menu-item .mi-title { font-size: 16px; font-weight: 600; }
.menu-item .mi-desc { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.menu-item .mi-badge {
  display: inline-block; margin-top: 8px; font-size: 11px; color: var(--red);
  background: #fdeceb; padding: 2px 8px; border-radius: 10px;
}
.menu-item.wide { grid-column: 1 / -1; }

/* ---------- 刷题 ---------- */
.quiz-head { display: flex; justify-content: space-between; align-items: center; margin: 14px 0 8px; }
.progress-track { height: 6px; background: #e8e3da; border-radius: 3px; overflow: hidden; margin-bottom: 14px; }
.progress-fill { height: 100%; background: var(--red); border-radius: 3px; transition: width .2s; }

.q-card { background: var(--card); border-radius: 12px; border: 1px solid var(--line); padding: 18px; }
.q-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.q-type { font-size: 12px; color: #fff; background: var(--red); padding: 2px 8px; border-radius: 4px; }
.q-type.multi { background: var(--orange); }
.q-type.judge { background: var(--green); }
.flag-btn {
  background: #f2eee6; border: 1px solid var(--line); border-radius: 16px;
  font-size: 14px; cursor: pointer; color: #a39a8b; padding: 5px 14px;
  transition: all .15s; white-space: nowrap;
}
.flag-btn:hover { border-color: var(--red); color: var(--red); }
.flag-btn.on { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
.q-stem { font-size: 16px; line-height: 1.7; margin-bottom: 14px; white-space: pre-wrap; }
.q-chapter { font-size: 12px; color: var(--muted); margin-bottom: 8px; }

.opt {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px;
  border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px;
  cursor: pointer; transition: border-color .12s, background .12s; font-size: 15px; line-height: 1.6;
}
.opt:hover { border-color: var(--red); }
.opt.selected { border-color: var(--red); background: #fdf0ee; }
.opt.correct { border-color: var(--green); background: #eafaf1; }
.opt.wrong { border-color: var(--bbb, #bbb); background: #fdeceb; }
.opt.disabled { cursor: default; }
.opt .key {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--line); display: flex; align-items: center; justify-content: center;
  font-size: 13px; margin-top: 1px;
}
.opt.selected .key { background: var(--red); color: #fff; border-color: var(--red); }
.opt.correct .key { background: var(--green); color: #fff; border-color: var(--green); }

.judge-row { display: flex; gap: 12px; }
.judge-row .opt { flex: 1; justify-content: center; font-size: 17px; }

.quiz-actions { display: flex; gap: 10px; margin-top: 16px; }
.quiz-actions .btn { flex: 1; }

.result-box {
  border-radius: 10px; padding: 14px; margin-top: 14px; font-size: 14px; line-height: 1.8;
}
.result-box.ok { background: #eafaf1; border: 1px solid #a9dfbf; }
.result-box.no { background: #fdeceb; border: 1px solid #f5b7b1; }
.result-box .ans { font-weight: 700; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: 12px; padding: 24px 20px; width: 100%; max-width: 360px;
}
.modal h3 { font-size: 17px; margin-bottom: 8px; }
.modal p { font-size: 13px; color: var(--muted); line-height: 1.7; margin-bottom: 18px; }
.modal .btn { width: 100%; margin-bottom: 10px; }

/* ---------- 列表（错题本/标注/管理） ---------- */
.list-item {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; margin-bottom: 10px;
}
.list-item .li-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; gap: 8px; }
.list-item .li-stem { font-size: 14px; line-height: 1.7; white-space: pre-wrap; }
.list-item .li-opts { font-size: 13px; color: #555; margin-top: 8px; line-height: 1.8; }
.list-item .li-ans { font-size: 13px; margin-top: 6px; color: var(--green); }
.list-item .li-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.tag {
  font-size: 11px; padding: 2px 8px; border-radius: 4px; background: #eee; color: #555;
  white-space: nowrap;
}
.tag.red { background: #fdeceb; color: var(--red); }
.tag.orange { background: #fdf2e9; color: var(--orange); }
.tag.green { background: #eafaf1; color: var(--green); }
.emphasis-badge {
  display: inline-block; font-size: 11px; color: #fff; background: var(--orange);
  padding: 2px 8px; border-radius: 4px; margin-left: 6px;
}

.back-bar { display: flex; align-items: center; gap: 12px; margin: 14px 0; }
.back-bar .spacer { flex: 1; }

.empty-tip { text-align: center; color: var(--muted); padding: 60px 0; font-size: 14px; }

.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; border-radius: 10px; overflow: hidden; }
.table th, .table td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; }
.table th { background: #faf7f2; font-weight: 600; font-size: 13px; }

.tabs { display: flex; gap: 8px; margin: 14px 0; flex-wrap: wrap; }
.tab {
  padding: 8px 16px; border-radius: 20px; background: #fff; border: 1px solid var(--line);
  cursor: pointer; font-size: 14px;
}
.tab.active { background: var(--red); color: #fff; border-color: var(--red); }

.search-row { display: flex; gap: 10px; margin-bottom: 14px; }
.search-row input { flex: 1; }

.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.75); color: #fff; padding: 10px 20px; border-radius: 8px;
  font-size: 14px; z-index: 200; max-width: 80%;
}
.mt { margin-top: 14px; }
.muted { color: var(--muted); font-size: 13px; }
