:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #1d2433;
  --ink-2: #5b6478;
  --ink-3: #8b94a8;
  --line: #e6e9f0;
  --accent: #3f62f5;
  --accent-soft: #eef2ff;
  --ok: #17a34a;
  --ok-soft: #eafaf0;
  --bad: #dc2626;
  --bad-soft: #fdeeee;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(18, 26, 45, .05), 0 8px 24px -12px rgba(18, 26, 45, .18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
    "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.65;
}

button { font-family: inherit; cursor: pointer; }

.app { max-width: 780px; margin: 0 auto; padding: 22px 18px 60px; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.logo {
  width: 40px; height: 40px; flex: 0 0 40px;
  border-radius: 12px;
  background: linear-gradient(140deg, #5b7cff, #3f62f5);
  color: #fff;
  font-weight: 700;
  font-size: 19px;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 16px -8px rgba(63, 98, 245, .9);
}

.brandtxt h1 { margin: 0; font-size: 17px; letter-spacing: .2px; }
.brandtxt p { margin: 0; font-size: 12px; color: var(--ink-3); }

.tabs { display: flex; gap: 4px; background: #eceff6; padding: 4px; border-radius: 11px; }

.tab {
  border: 0; background: transparent; color: var(--ink-2);
  padding: 6px 15px; border-radius: 8px; font-size: 13.5px; font-weight: 600;
  transition: .16s;
}
.tab.is-on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(20, 30, 60, .12); }

/* ---------- 卡片 ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 12px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat b { display: block; font-size: 21px; letter-spacing: -.4px; }
.stat span { font-size: 11.5px; color: var(--ink-3); }

/* ---------- 面板 ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.panel h2 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: .3px;
}

/* ---------- 表单 ---------- */
.field { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.field > label { flex: 0 0 46px; font-size: 13px; color: var(--ink-2); font-weight: 600; }

select {
  flex: 1;
  appearance: none;
  border: 1px solid var(--line);
  background: #fbfcfe url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238b94a8' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  border-radius: 10px;
  padding: 9px 34px 9px 12px;
  font-size: 14px;
  color: var(--ink);
  font-family: inherit;
}
select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  border: 1px solid var(--line);
  background: #fbfcfe;
  color: var(--ink-2);
  padding: 7px 13px;
  border-radius: 9px;
  font-size: 13px;
  transition: .15s;
}
.seg button:hover { border-color: #c9d2e6; }
.seg button.is-on {
  background: var(--accent-soft);
  border-color: #c3cffd;
  color: var(--accent);
  font-weight: 600;
}

.deckhint {
  margin: 2px 0 16px;
  font-size: 12.5px;
  color: var(--ink-3);
  min-height: 18px;
}

/* ---------- 按钮 ---------- */
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions.center { justify-content: center; }

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  transition: .15s;
  box-shadow: 0 1px 2px rgba(18, 26, 45, .04);
}
.btn:hover { border-color: #c9d2e6; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn.primary {
  background: linear-gradient(140deg, #5b7cff, #3f62f5);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 18px -10px rgba(63, 98, 245, .95);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; box-shadow: none; color: var(--ink-2); }
.btn.danger { color: var(--bad); border-color: #f3d2d2; background: var(--bad-soft); }
.btn.danger:hover { border-color: #eebbbb; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.link {
  border: 0; background: none; padding: 0;
  color: var(--ink-2); font-size: 13px; font-weight: 600;
}
.link:hover { color: var(--accent); }

/* ---------- 章节列表 ---------- */
.chlist { display: flex; flex-direction: column; gap: 12px; }

.chrow .chhead {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; margin-bottom: 5px;
}
.chhead .chname { font-weight: 600; }
.chhead .chnum { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.chbar { height: 7px; background: #eef1f7; border-radius: 6px; overflow: hidden; }
.chbar i {
  display: block; height: 100%; border-radius: 6px;
  background: linear-gradient(90deg, #6f8bff, #3f62f5);
  transition: width .35s ease;
}

/* ---------- 答题区 ---------- */
.qbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; gap: 10px;
}
.qmeta { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.qmeta .sep { margin: 0 6px; color: #c8cfdd; }

.track { height: 5px; background: #e6eaf3; border-radius: 4px; overflow: hidden; margin-bottom: 16px; }
.track-bar {
  height: 100%; width: 0;
  background: linear-gradient(90deg, #7f97ff, #3f62f5);
  border-radius: 4px; transition: width .3s ease;
}

.qcard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.qno { font-size: 12px; color: var(--ink-3); margin-bottom: 8px; font-weight: 600; letter-spacing: .4px; }

.qstem {
  font-size: 16.5px;
  font-weight: 600;
  line-height: 1.7;
  margin-bottom: 18px;
  letter-spacing: .1px;
}

.options { display: flex; flex-direction: column; gap: 9px; }

.opt {
  display: flex; align-items: flex-start; gap: 12px;
  width: 100%; text-align: left;
  border: 1px solid var(--line);
  background: #fbfcfe;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14.5px;
  color: var(--ink);
  line-height: 1.6;
  transition: .14s;
}
.opt:hover { border-color: #bcc9ee; background: #f7f9ff; }

.opt .letter {
  flex: 0 0 24px; height: 24px;
  border-radius: 7px;
  background: #eef1f8;
  color: var(--ink-2);
  font-size: 12.5px; font-weight: 700;
  display: grid; place-items: center;
  margin-top: 1px;
}
.opt .otext { flex: 1; }

.opt.correct { border-color: #9ad9b2; background: var(--ok-soft); }
.opt.correct .letter { background: var(--ok); color: #fff; }

.opt.wrong { border-color: #f0b4b4; background: var(--bad-soft); }
.opt.wrong .letter { background: var(--bad); color: #fff; }

.opt.dim { opacity: .55; }
.opt.locked { pointer-events: none; }

/* ---------- 解析 ---------- */
.explain {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  animation: fade .22s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

.verdict { font-size: 13.5px; font-weight: 700; margin-bottom: 8px; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--bad); }
.exptext { font-size: 13.5px; color: var(--ink-2); line-height: 1.8; }

/* ---------- 底部导航 ---------- */
.qfoot { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; }
.qfoot .btn { flex: 1; }

/* ---------- 完成 ---------- */
.qcard.done { text-align: center; padding: 34px 22px; }
.doneicon {
  width: 54px; height: 54px; margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--ok-soft); color: var(--ok);
  font-size: 26px; display: grid; place-items: center;
  border: 1px solid #c8ecda;
}
.qcard.done h2 { margin: 0 0 8px; font-size: 17px; }
.donetext { margin: 0 0 20px; color: var(--ink-2); font-size: 14px; }

/* ---------- 周统计 ---------- */
.week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  align-items: end;
  height: 132px;
}
.day { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.day .dnum { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.day .dbar {
  width: 100%;
  background: #eef1f7;
  border-radius: 7px;
  height: 84px;
  display: flex; align-items: flex-end;
  overflow: hidden;
}
.day .dbar i {
  display: block; width: 100%;
  background: linear-gradient(180deg, #7f97ff, #3f62f5);
  border-radius: 7px;
  transition: height .3s ease;
  min-height: 0;
}
.day .dlabel { font-size: 11px; color: var(--ink-3); }
.day.is-today .dlabel { color: var(--accent); font-weight: 700; }

/* ---------- 其它 ---------- */
.foot { text-align: center; font-size: 12px; color: var(--ink-3); margin: 16px 0 0; }
.warn { font-size: 13px; color: var(--ink-2); margin: 0 0 12px; }

.view[hidden] { display: none; }

@media (max-width: 560px) {
  .app { padding: 16px 12px 50px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .brandtxt p { display: none; }
  .qstem { font-size: 15.5px; }
  .qcard { padding: 17px; border-radius: 15px; }
  .field { align-items: flex-start; flex-direction: column; gap: 8px; }
  .field > label { flex: none; }
  .qfoot .btn { padding: 11px 10px; }
  .qmeta { font-size: 11.5px; }
}
