:root {
  --accent: #c0392b;
  --accent-2: #e74c3c;
  --ok: #1e8e4f;
  --ok-bg: #e7f6ec;
  --bad: #c0392b;
  --bad-bg: #fdecea;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #6b7785;
  --line: #e3e8ee;
  --shadow: 0 2px 12px rgba(20, 30, 50, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding-bottom: 72px; /* 底部导航占位 */
}

/* 顶栏 */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 26px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 17px; }
.brand-text small { font-size: 11px; opacity: 0.9; }
.icon-btn {
  background: rgba(255,255,255,0.18); border: none; color: #fff;
  width: 38px; height: 38px; border-radius: 10px; font-size: 20px; cursor: pointer;
}
.icon-btn:active { background: rgba(255,255,255,0.32); }

.view { max-width: 860px; margin: 0 auto; padding: 14px 14px 28px; }

/* 卡片 */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px; border: 1px solid var(--line);
}
h2.section { font-size: 18px; margin: 4px 2px 12px; }
.muted { color: var(--muted); }

/* 统计数字 */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 10px; text-align: center;
}
.stat .num { font-size: 26px; font-weight: 800; color: var(--accent); }
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 12px; padding: 13px 16px; font-size: 15px; font-weight: 600;
  cursor: pointer; width: 100%; transition: transform .05s, opacity .2s; background: var(--accent); color: #fff;
}
.btn:active { transform: scale(0.98); }
.btn.secondary { background: #eef1f5; color: var(--text); }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* 模式/筛选选择 */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 8px 14px; border-radius: 999px; font-size: 14px; cursor: pointer;
}
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.field { margin: 10px 0; }
.field > label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.inp {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 15px; background: #fff; color: var(--text);
}
.inp:focus { outline: none; border-color: var(--accent); }

/* 题目卡片 */
.q-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.badge { font-size: 12px; padding: 3px 9px; border-radius: 999px; font-weight: 700; }
.badge.judge { background: #eaf2ff; color: #2563eb; }
.badge.single { background: #fff3e0; color: #d97706; }
.badge.multiple { background: #f3e8ff; color: #7c3aed; }
.badge.admin { background: #c0392b; color: #fff; }

/* 用户管理看板 */
.usr-list { display: flex; flex-direction: column; gap: 10px; }
.usr-row { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: #fff; }
.usr-name { font-weight: 700; font-size: 15px; margin-bottom: 2px; }
.usr-stat { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.usr-stat b { color: var(--text); font-size: 14px; }
.usr-tool { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.usr-tool .inp { flex: 1; min-width: 84px; }
.usr-act { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.mini { font-size: 12px; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text); cursor: pointer; }
.mini.danger { color: #c0392b; border-color: #f0c0bb; }
.mini:disabled { opacity: .4; cursor: not-allowed; }
.usr-row.disabled { opacity: .6; background: #fafafa; }
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 14px; padding: 18px; width: min(92vw, 360px); }
.pwd-box { background: #f4f4f5; border-radius: 8px; padding: 10px; font-family: monospace; font-size: 16px; text-align: center; letter-spacing: 1px; margin: 6px 0 12px; word-break: break-all; color: #111; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: #f0f2f5; color: var(--muted); }
.q-stem { font-size: 17px; font-weight: 600; margin: 8px 0 14px; white-space: pre-wrap; }

/* 选项 */
.options { display: grid; gap: 10px; }
.option {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; background: #fff;
  transition: border-color .15s, background .15s;
}
.option:hover { border-color: #c9d2dd; }
.option .key {
  flex: 0 0 26px; height: 26px; border-radius: 50%; background: #eef1f5; color: var(--muted);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}
.option.selected { border-color: var(--accent); background: #fff5f3; }
.option.selected .key { background: var(--accent); color: #fff; }
.option.correct { border-color: var(--ok); background: var(--ok-bg); }
.option.correct .key { background: var(--ok); color: #fff; }
.option.wrong { border-color: var(--bad); background: var(--bad-bg); }
.option.wrong .key { background: var(--bad); color: #fff; }
.option .txt { flex: 1; }

/* 进度条 */
.progress { height: 6px; background: #e6eaef; border-radius: 99px; overflow: hidden; margin: 4px 0 12px; }
.progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .25s; }

/* 答题结果 */
.result { margin-top: 14px; padding: 12px 14px; border-radius: 12px; font-size: 14px; }
.result.ok { background: var(--ok-bg); color: var(--ok); }
.result.no { background: var(--bad-bg); color: var(--bad); }
.result .right-ans { font-weight: 700; }

/* 错题/收藏列表 */
.q-item { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.q-item:last-child { border-bottom: none; }
.q-item .idx { flex: 0 0 26px; height: 26px; border-radius: 8px; background: #eef1f5; color: var(--muted);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }
.q-item .body { flex: 1; }
.q-item .body .s { font-size: 14px; }
.q-item .body .meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* 题号导航（模考） */
.qnav { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: 10px 0; }
.qnav button {
  aspect-ratio: 1/1; border: 1px solid var(--line); background: #fff; border-radius: 8px;
  font-size: 13px; cursor: pointer; color: var(--muted);
}
.qnav button.answered { background: #eaf2ff; color: #2563eb; border-color: #bcd2ff; }
.qnav button.current { outline: 2px solid var(--accent); }
.qnav button.wrong { background: var(--bad-bg); color: var(--bad); border-color: #f3b5ad; }

/* 计时器 */
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 18px; color: var(--accent); }

/* 底部导航 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; border: none; background: none; padding: 8px 0 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 11px;
}
.tab span { font-size: 11px; }
.tab.active { color: var(--accent); font-weight: 700; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: rgba(20,28,40,0.92); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 登录/注册 切换 */
.seg { display: flex; background: #eef1f5; border-radius: 10px; padding: 4px; margin-bottom: 14px; }
.seg button {
  flex: 1; border: none; background: none; padding: 10px 0; border-radius: 8px; font-size: 15px;
  font-weight: 600; color: var(--muted); cursor: pointer; transition: background .15s, color .15s;
}
.seg button.on { background: #fff; color: var(--accent); box-shadow: var(--shadow); }

/* 我的 - 资料卡 */
.me-head { display: flex; align-items: center; gap: 14px; }
.avatar {
  flex: 0 0 52px; height: 52px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 800;
}
.me-name { font-size: 19px; font-weight: 700; }

/* 记录列表 */
.rec-list { display: flex; flex-direction: column; }
.rec-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center;
  padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.rec-row:last-child { border-bottom: none; }
.rec-row > span:first-child { color: var(--muted); font-size: 13px; }

/* 底部导航：已登录标记 */
.tab.logged::after {
  content: ""; position: absolute; top: 6px; right: 50%; transform: translateX(18px);
  width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 2px #fff;
}
.tab { position: relative; }

/* 桌面/平板适配 */
@media (min-width: 768px) {
  .view { padding: 22px 18px 30px; }
  .appbar { padding: 14px 28px; }
  .options { gap: 12px; }
  .option { padding: 14px 18px; font-size: 16px; }
  .q-stem { font-size: 19px; }
  .stat .num { font-size: 32px; }
  .tabbar { max-width: 860px; margin: 0 auto; left: 50%; transform: translateX(-50%); border-radius: 16px 16px 0 0; bottom: 8px; box-shadow: var(--shadow); }
  body { padding-bottom: 84px; }
}
@media (min-width: 1100px) {
  .view { max-width: 980px; }
}
