/* ===== CDA LEVEL I 备考系统 · CDA 深蓝主题 ===== */
:root {
  --c-primary: #143a6b;
  --c-primary-2: #2456a6;
  --c-primary-lt: #e8f0fb;
  --c-success: #1f9d57;
  --c-success-lt: #dcfce7;
  --c-danger: #e0413e;
  --c-danger-lt: #fde8e7;
  --c-warn: #e69500;
  --c-bg: #f3f6fc;
  --c-surface: #ffffff;
  --c-surface-2: #eef2f9;
  --c-line: #e1e8f2;
  --c-text: #1b2733;
  --c-text-2: #6b7886;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(20, 58, 107, .10);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--c-bg); color: var(--c-text); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
.hidden, [hidden] { display: none !important; }

/* ===== 布局 ===== */
#app { min-height: 100vh; display: flex; flex-direction: column; }
#topbar { height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--c-primary); color: #fff; position: sticky; top: 0; z-index: 30; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.brand { font-weight: 800; font-size: 18px; letter-spacing: .5px; }
.brand span { color: #8fc0ff; }
.user-box { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-box .hello { font-size: 14px; font-weight: 600; }
.rail-toggle { display: none; background: rgba(255,255,255,.12); color: #fff; border: none;
  width: 40px; height: 40px; border-radius: 10px; font-size: 20px; cursor: pointer; }

.body-wrap { flex: 1; display: flex; align-items: stretch; }
#sidebar { width: 248px; flex: 0 0 248px; background: var(--c-surface); border-right: 1px solid var(--c-line);
  padding: 14px 10px; position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 10px;
  color: var(--c-text); text-decoration: none; font-size: 15px; font-weight: 600; cursor: pointer; position: relative; }
.nav-link span { flex: 1; }
.nav-link:hover { background: var(--c-surface-2); }
.nav-link.active { background: var(--c-primary-lt); color: var(--c-primary); }
.nav-group.has-sub > .nav-parent { justify-content: space-between; }
.nav-group.has-sub > .nav-parent::after { content: "▸"; font-size: 12px; color: var(--c-text-2); transition: transform .2s; }
.nav-group.has-sub.open > .nav-parent::after { transform: rotate(90deg); }
.nav-sub { display: none; flex-direction: column; gap: 2px; padding: 2px 0 2px 14px; margin-left: 8px;
  border-left: 2px solid var(--c-line); }
.nav-group.has-sub.open > .nav-sub { display: flex; }
.nav-child { font-size: 13.5px; font-weight: 500; padding: 8px 12px; color: var(--c-text-2); }
.nav-child.muted { color: #aab4c0; font-style: italic; }
.nav-badge { background: var(--c-danger); color: #fff; border-radius: 10px; font-size: 11px;
  min-width: 18px; height: 18px; display: inline-grid; place-items: center; padding: 0 5px; }

#main { flex: 1; min-width: 0; }
.view { max-width: min(1080px, 100%); margin: 0 auto; padding: 20px 18px 60px; }

/* ===== 按钮 ===== */
.btn { min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--c-line);
  background: var(--c-surface); color: var(--c-text); font-size: 15px; font-weight: 700; cursor: pointer; }
.btn:hover { border-color: var(--c-primary-2); }
.btn.primary { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.btn.primary:hover { background: var(--c-primary-2); }
.btn.ghost { background: transparent; color: var(--c-text-2); }
.btn.block { display: block; width: 100%; }
.btn.tiny { min-height: 36px; padding: 0 14px; font-size: 13px; }

/* ===== dashboard ===== */
.login-banner { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  background: linear-gradient(90deg, var(--c-primary), var(--c-primary-2)); color: #fff; padding: 16px 18px;
  border-radius: var(--radius); margin-bottom: 18px; }
.login-banner .lb-text { font-size: 14px; }
.login-banner .btn.primary { background: #fff; color: var(--c-primary); border-color: #fff; }
.hero { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow); margin-bottom: 18px; }
.hero-hello { font-size: 22px; font-weight: 800; }
.hero-date { color: var(--c-text-2); margin: 6px 0 16px; font-size: 14px; }
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.mod-card { text-align: left; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--radius);
  padding: 18px; cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s; position: relative; }
.mod-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--c-primary-2); }
.mc-icon { font-size: 30px; }
.mc-name { font-size: 17px; font-weight: 800; margin: 8px 0 4px; }
.mc-desc { font-size: 13px; color: var(--c-text-2); min-height: 34px; }
.mc-badge { display: inline-block; margin-top: 10px; background: var(--c-primary-lt); color: var(--c-primary);
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 8px; }

/* ===== 章节/试卷卡片列表 ===== */
.rail-wide { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.rail-ch { text-align: left; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--radius);
  padding: 16px; cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s; }
.rail-ch:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--c-primary-2); }
.cc-name { font-size: 15px; font-weight: 800; }
.cc-meta { font-size: 12.5px; color: var(--c-text-2); margin: 8px 0; }
.cc-progress { height: 7px; background: var(--c-surface-2); border-radius: 5px; overflow: hidden; }
.cc-progress > i { display: block; height: 100%; background: var(--c-primary); border-radius: 5px; }
.cc-cta { margin-top: 12px; font-size: 13px; font-weight: 700; color: var(--c-primary); }

/* ===== 答题卡片 ===== */
.q-card { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); }
.q-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.q-type { font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 8px; }
.q-type.single { background: var(--c-primary-lt); color: var(--c-primary); }
.q-type.multi { background: #fff1e6; color: #c2670a; }
.q-src { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 7px; background: var(--c-surface-2); color: var(--c-text-2); }
.q-idx { margin-left: auto; font-size: 13px; color: var(--c-text-2); }
.q-text { font-size: 16.5px; line-height: 1.7; font-weight: 600; margin-bottom: 16px; }
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt { display: flex; align-items: flex-start; gap: 12px; text-align: left; background: var(--c-surface);
  border: 1.5px solid var(--c-line); border-radius: 12px; padding: 13px 14px; cursor: pointer; font-size: 15px;
  transition: border-color .12s, background .12s; }
.opt:hover { border-color: var(--c-primary-2); }
.opt.sel { border-color: var(--c-primary); background: var(--c-primary-lt); }
.opt.correct { border-color: var(--c-success); background: var(--c-success-lt); }
.opt.wrong { border-color: var(--c-danger); background: var(--c-danger-lt); }
.opt.disabled { cursor: default; }
.opt-l { flex: 0 0 26px; height: 26px; border-radius: 50%; background: var(--c-surface-2); color: var(--c-primary);
  display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.opt-t { flex: 1; line-height: 1.55; }
.q-actions { margin-top: 16px; }
.done-tip { text-align: center; color: var(--c-success); font-weight: 700; padding: 10px; }
.fav-btn { margin-top: 14px; background: none; border: none; color: var(--c-warn); font-size: 14px; font-weight: 700; cursor: pointer; }

.reveal { margin-top: 14px; border-radius: 12px; padding: 14px 16px; background: var(--c-surface-2); display: none; }
.reveal.show { display: block; }
.reveal.ok { background: var(--c-success-lt); }
.reveal.no { background: var(--c-danger-lt); }
.ans-line { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.ans-analysis { font-size: 14px; line-height: 1.7; color: var(--c-text); }
.ans-analysis.muted { color: var(--c-text-2); }
.tag-ok { color: var(--c-success); }
.tag-no { color: var(--c-danger); }

/* ===== 考试模式 ===== */
.exambar { display: flex; align-items: center; justify-content: space-between; background: var(--c-primary-lt);
  padding: 10px 16px; border-radius: 12px; margin-bottom: 16px; }
.exam-timer-wrap { font-size: 14px; color: var(--c-text-2); font-weight: 600; }
.exam-timer { font-size: 22px; font-weight: 800; color: var(--c-primary); font-variant-numeric: tabular-nums; }
.exam-timer.warn { color: var(--c-danger); }
.exam-wrap { display: flex; gap: 18px; align-items: flex-start; }
.exam-palette { flex: 0 0 132px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px;
  background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 12px; padding: 12px; }
.pal-item { width: 100%; aspect-ratio: 1; border: 1px solid var(--c-line); background: var(--c-surface-2);
  border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer; color: var(--c-text-2); }
.pal-item.answered { background: #cfe0fb; color: var(--c-primary); border-color: #cfe0fb; }
.pal-item.current { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.waiting-box { text-align: center; padding: 70px 20px; }
.wb-ico { font-size: 48px; }
.wb-msg { font-size: 17px; font-weight: 700; margin: 12px 0 20px; }

/* ===== 成绩报告 ===== */
.complete-page { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--radius);
  padding: 26px; box-shadow: var(--shadow); text-align: center; }
.ring-wrap { display: flex; justify-content: center; margin: 6px 0 18px; }
.ring { width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--c-primary) calc(var(--p) * 1%), var(--c-surface-2) 0); position: relative; }
.ring::before { content: ""; position: absolute; inset: 14px; background: var(--c-surface); border-radius: 50%; }
.ring-num { position: relative; font-size: 34px; font-weight: 800; color: var(--c-primary); }
.ring-sub { position: relative; font-size: 13px; color: var(--c-text-2); }
.complete-stats { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.cstat { background: var(--c-surface-2); border-radius: 12px; padding: 12px 18px; min-width: 84px; }
.cstat-v { font-size: 22px; font-weight: 800; color: var(--c-primary); }
.cstat-l { font-size: 12px; color: var(--c-text-2); }
.weak-box { margin: 8px 0 16px; }
.weak-title { font-size: 14px; font-weight: 700; color: var(--c-text-2); margin-bottom: 8px; }
.weak-list { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.weak-tag { background: var(--c-danger-lt); color: var(--c-danger); font-size: 13px; font-weight: 700;
  padding: 5px 12px; border-radius: 9px; }
.action-group { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ===== 知识卡 ===== */
.kb-single { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; }
.kb-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.kb-ch-name { font-weight: 800; color: var(--c-primary); }
.kb-pos { font-size: 13px; color: var(--c-text-2); }
.flashcard-page { display: flex; flex-direction: column; }
.flashcard { perspective: 1200px; margin-bottom: 4px; }
.flashcard-inner { position: relative; width: 100%; min-height: 340px; transform-style: preserve-3d;
  transition: transform .5s; }
.flashcard-inner.flipped { transform: rotateY(180deg); }
.flashcard-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 16px; padding: 24px; background: var(--c-surface); border: 1px solid var(--c-line); box-shadow: var(--shadow); }
.fc-back { transform: rotateY(180deg); overflow: auto; }
.fc-kicker { font-size: 12px; font-weight: 700; color: var(--c-primary-2); margin-bottom: 12px; }
.fc-title { font-size: 20px; font-weight: 800; line-height: 1.5; }
.fc-hint { position: absolute; bottom: 18px; left: 0; right: 0; text-align: center; color: var(--c-text-2); font-size: 13px; }
.article-body { line-height: 1.8; font-size: 15px; }
.article-body mark { background: #fff3bf; padding: 0 2px; border-radius: 3px; }
.article-body .md-ul { padding-left: 20px; }
.article-body .md-ul li { margin: 4px 0; }
.fc-actions { display: flex; gap: 12px; margin-top: 12px; }
.fc-btn { flex: 1; min-height: 48px; border-radius: 12px; border: none; font-weight: 800; font-size: 15px; cursor: pointer; }
.fc-btn.yes { background: var(--c-success); color: #fff; }
.fc-btn.no { background: var(--c-surface-2); color: var(--c-text); }
.stage-nav { display: flex; gap: 10px; margin-top: 14px; }
.stage-nav .btn { flex: 1; }

/* ===== 错题 / 收藏 ===== */
.mb-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.mb-title { font-size: 19px; font-weight: 800; }
.mb-seg { display: flex; gap: 6px; }
.seg { min-height: 34px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--c-line); background: var(--c-surface);
  font-size: 13px; font-weight: 700; cursor: pointer; color: var(--c-text-2); }
.seg.on { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.mb-item { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.mb-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--c-text-2); margin-bottom: 8px; }
.mb-badge { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 7px; }
.mb-badge.ok { background: var(--c-success-lt); color: var(--c-success); }
.mb-badge.no { background: var(--c-danger-lt); color: var(--c-danger); }
.mb-count { background: var(--c-surface-2); padding: 1px 7px; border-radius: 7px; }
.mb-qtext { font-size: 15.5px; line-height: 1.6; font-weight: 600; margin-bottom: 12px; }
.mb-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.mb-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.mb-page { font-size: 13px; color: var(--c-text-2); font-weight: 700; }
.mb-clear { margin-top: 14px; text-align: center; }

/* ===== 弹窗 / 状态 / toast ===== */
.modal-mask { position: fixed; inset: 0; background: rgba(10, 20, 40, .45); display: grid; place-items: center;
  z-index: 60; padding: 20px; }
.modal { background: var(--c-surface); border-radius: 16px; padding: 22px; width: min(420px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-title { margin: 0 0 6px; font-size: 18px; }
.modal-sub { margin: 0 0 14px; color: var(--c-text-2); font-size: 13px; }
.modal-input { width: 100%; min-height: 46px; padding: 0 12px; font-size: 16px; border: 1px solid var(--c-line); border-radius: 10px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.modal-err { color: var(--c-danger); font-size: 13px; min-height: 18px; margin: 8px 0 0; }
.state-box { text-align: center; padding: 56px 20px; color: var(--c-text-2); }
.state-box .ico { font-size: 40px; display: block; margin-bottom: 12px; }
.state-box .msg { font-size: 15px; margin-bottom: 6px; color: var(--c-text); }
.state-box .sub { font-size: 13px; margin-bottom: 18px; max-width: 420px; margin-left: auto; margin-right: auto; word-break: break-all; }
.state-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.loading-box { text-align: center; padding: 60px 20px; color: var(--c-text-2); }
.toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(20px); background: rgba(20,40,70,.94);
  color: #fff; padding: 11px 20px; border-radius: 10px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 80; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* markdown 表格 */
.md-table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 14px; }
.md-table th, .md-table td { border: 1px solid var(--c-line); padding: 6px 10px; text-align: left; }
.md-table th { background: var(--c-surface-2); }
code { background: var(--c-surface-2); padding: 1px 5px; border-radius: 5px; font-size: 13px; }

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
  .rail-toggle { display: block; }
  #sidebar { position: fixed; top: 60px; left: 0; z-index: 40; transform: translateX(-100%); transition: transform .25s;
    box-shadow: 0 0 40px rgba(0,0,0,.2); }
  #sidebar.open { transform: translateX(0); }
  .rail-overlay { position: fixed; inset: 60px 0 0 0; background: rgba(0,0,0,.35); z-index: 39; display: none; }
  .rail-overlay.show { display: block; }
  .exam-wrap { flex-direction: column; }
  .exam-palette { flex-direction: row; flex-wrap: wrap; width: 100%; }
}
@media (max-width: 640px) {
  .view { padding: 14px 12px 50px; }
  .btn { width: 100%; }
  .mod-grid { grid-template-columns: 1fr; }
  .hero-hello { font-size: 19px; }
  .q-text { font-size: 15.5px; }
}
