:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #16181d;
  --text-2: #5b6472;
  --text-3: #8b95a4;
  --line: #e7eaef;
  --primary: #2f6bff;
  --primary-soft: #eaf0ff;
  --right: #12a150;
  --right-soft: #e7f7ee;
  --wrong: #e5484d;
  --wrong-soft: #fdecec;
  --warn: #c47f17;
  --warn-soft: #fdf4e3;
  --radius: 16px;
  --nav-h: 62px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --card: #171b22;
    --text: #e9edf3;
    --text-2: #9aa5b5;
    --text-3: #6c7788;
    --line: #242a34;
    --primary: #5b8cff;
    --primary-soft: #1b2540;
    --right: #35c46f;
    --right-soft: #14301f;
    --wrong: #ff6b6f;
    --wrong-soft: #36191b;
    --warn: #e0a83c;
    --warn-soft: #33280f;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 8px); }

.wrap { max-width: 560px; margin: 0 auto; padding: 16px 16px 24px; }

/* ---------- 顶部 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 650; letter-spacing: .2px; }
.topbar .spacer { flex: 1; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text-2);
  display: grid; place-items: center; font-size: 16px; cursor: pointer;
}
.icon-btn:active { transform: scale(.96); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card.tight { padding: 12px 14px; }
.card h2 { font-size: 15px; margin: 0 0 10px; font-weight: 650; }
.card h2 .hint { font-weight: 400; font-size: 12px; color: var(--text-3); margin-left: 6px; }

.muted { color: var(--text-2); }
.dim { color: var(--text-3); font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1; min-width: 0; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 0 18px;
  border-radius: 12px; border: 1px solid transparent;
  background: var(--primary); color: #fff;
  font-size: 15px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: transform .06s ease, opacity .15s;
}
.btn:active { transform: scale(.985); opacity: .92; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.ghost { background: var(--card); color: var(--text); border-color: var(--line); }
.btn.soft { background: var(--primary-soft); color: var(--primary); }
.btn.block { display: flex; width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.input {
  width: 100%; min-height: 46px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--text);
  font-size: 16px; font-family: inherit; outline: none;
}
.input:focus { border-color: var(--primary); background: var(--card); }

/* ---------- 底部导航 ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.nav a {
  flex: 1; text-decoration: none; color: var(--text-3);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; font-size: 11px;
}
.nav a .ico { font-size: 19px; line-height: 1; }
.nav a.on { color: var(--primary); font-weight: 600; }

/* ---------- 进度 ---------- */
.bar { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--primary); transition: width .3s ease; }

/* ---------- 选项 ---------- */
.opts { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.opt {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px; min-height: 52px;
  border: 1.5px solid var(--line); border-radius: 14px;
  background: var(--card); color: var(--text);
  font-size: 15px; line-height: 1.5; text-align: left;
  font-family: inherit; cursor: pointer; transition: border-color .15s, background .15s;
}
.opt:active { transform: scale(.995); }
.opt .k {
  flex: none; width: 24px; height: 24px; border-radius: 7px;
  display: grid; place-items: center;
  background: var(--bg); color: var(--text-2);
  font-size: 13px; font-weight: 700; border: 1px solid var(--line);
}
.opt.sel { border-color: var(--primary); background: var(--primary-soft); }
.opt.sel .k { background: var(--primary); color: #fff; border-color: var(--primary); }
.opt.right { border-color: var(--right); background: var(--right-soft); }
.opt.right .k { background: var(--right); color: #fff; border-color: var(--right); }
.opt.wrong { border-color: var(--wrong); background: var(--wrong-soft); }
.opt.wrong .k { background: var(--wrong); color: #fff; border-color: var(--wrong); }
.opt[disabled] { cursor: default; }

/* ---------- 解析 ---------- */
.ans-box {
  border-radius: 14px; padding: 14px; margin-top: 14px;
  font-size: 14px; line-height: 1.65;
}
.ans-box.ok { background: var(--right-soft); }
.ans-box.no { background: var(--wrong-soft); }
.ans-box .verdict { font-weight: 700; margin-bottom: 8px; font-size: 15px; }
.ans-box.ok .verdict { color: var(--right); }
.ans-box.no .verdict { color: var(--wrong); }
.ans-box .sec { margin-top: 10px; }
.ans-box .sec b { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 2px; font-weight: 600; }
.anchor {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px;
  background: var(--card); border: 1px dashed var(--line);
  font-size: 13.5px; color: var(--text);
}
.mis {
  margin-top: 8px; padding-left: 12px; border-left: 2px solid var(--wrong);
  font-size: 13px; color: var(--text-2);
}

/* ---------- 徽标 ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 99px;
  font-size: 11.5px; font-weight: 600; line-height: 1.6;
  background: var(--bg); color: var(--text-2); border: 1px solid var(--line);
}
.chip.ok { background: var(--right-soft); color: var(--right); border-color: transparent; }
.chip.bad { background: var(--wrong-soft); color: var(--wrong); border-color: transparent; }
.chip.mid { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.pri { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

/* ---------- 列表 ---------- */
.list { display: flex; flex-direction: column; }
.list > a, .list > div.row { text-decoration: none; color: var(--text); }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid var(--line);
  text-decoration: none; color: var(--text);
}
.list-item:last-child { border-bottom: 0; }
.list-item .t { font-size: 15px; font-weight: 550; }
.list-item .d { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.list-item.disabled { opacity: .5; }

/* ---------- 统计 ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { text-align: center; padding: 10px 4px; }
.stat .n { font-size: 22px; font-weight: 700; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

/* ---------- 热力日历 ---------- */
.cal-wrap { max-width: 322px; }
.cal-head {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  margin-bottom: 5px;
}
.cal-head span { font-size: 11px; color: var(--text-3); text-align: center; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal i {
  aspect-ratio: 1; border-radius: 5px; background: var(--line);
  font-size: 0; display: block;
}
.cal i.pad { background: transparent; }
.cal i.l1 { background: color-mix(in srgb, var(--primary) 25%, var(--line)); }
.cal i.l2 { background: color-mix(in srgb, var(--primary) 50%, var(--line)); }
.cal i.l3 { background: color-mix(in srgb, var(--primary) 75%, var(--line)); }
.cal i.l4 { background: var(--primary); }

/* ---------- 知识点条 ---------- */
.kp { padding: 11px 0; border-bottom: 1px solid var(--line); }
.kp:last-child { border-bottom: 0; }
.kp .head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.kp .name { font-size: 14px; font-weight: 550; }
.kp .val { font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; flex: none; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--text-3); }
.empty .ico { font-size: 40px; opacity: .5; display: block; margin-bottom: 10px; }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 24px);
  transform: translateX(-50%) translateY(10px);
  background: #1f2430; color: #fff;
  padding: 10px 18px; border-radius: 99px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .22s ease; z-index: 99;
  max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 管理页 ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 9px 8px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { color: var(--text-3); font-weight: 600; font-size: 12px; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
