/* ============================================================
   宠卡培训 H5 · 学习 + 答题
   配色取自官网 CSS 变量，保证与品牌视觉一致
   ============================================================ */

:root {
  --brown: #6B4423;
  --brown-light: #8D6E63;
  --brown-dark: #4E3019;
  --yellow: #F5A623;
  --yellow-light: #FDE8B6;
  --yellow-soft: #FFF3D6;
  --cream: #FFF9F0;
  --cream-warm: #FFF5E6;
  --white: #FFFFFF;
  --pink: #FFE4E1;
  --green: #D4F5D4;
  --green-ink: #2E7D32;
  --red-ink: #C0392B;
  --text: #4A3B2A;
  --text-light: #7A6B5A;
  --gray: #9B8B7A;
  --line: #E8DCCB;
  --shadow: 0 8px 32px rgba(107, 68, 35, .12);
  --shadow-sm: 0 2px 10px rgba(107, 68, 35, .08);
  --r: 16px;
  --r-lg: 24px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

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

body { padding-bottom: calc(76px + var(--safe-b)); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--white);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-sm);
}
.topbar .brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; color: var(--brown); font-size: 16px;
  min-width: 0;
}
.topbar .brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--yellow); flex: none;
  box-shadow: 0 0 0 3px var(--yellow-soft);
}
.topbar .brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.topbar button.ghost {
  border: 1px solid var(--line); background: var(--cream);
  color: var(--brown); border-radius: 999px;
  padding: 6px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; flex: none;
}
.topbar button.ghost:active { background: var(--yellow-soft); }

/* ---------- 视图 ---------- */
.view { display: none; padding: 16px; max-width: 720px; margin: 0 auto; }
.view.active { display: block; }

/* ---------- 首页 ---------- */
.hero {
  background: linear-gradient(150deg, var(--brown) 0%, var(--brown-dark) 100%);
  border-radius: var(--r-lg);
  padding: 26px 22px;
  color: #fff;
  position: relative; overflow: hidden;
  margin-bottom: 16px;
}
.hero::after {
  content: ""; position: absolute; right: -40px; top: -40px;
  width: 150px; height: 150px; border-radius: 50%;
  background: rgba(245,166,35,.22);
}
.hero h1 { margin: 0 0 6px; font-size: 23px; letter-spacing: .5px; }
.hero p { margin: 0; font-size: 13.5px; opacity: .88; line-height: 1.6; }
.hero .tag {
  display: inline-block; margin-top: 14px;
  background: var(--yellow); color: var(--brown-dark);
  font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 999px;
}

.card {
  background: var(--white); border-radius: var(--r);
  padding: 18px; margin-bottom: 14px;
  box-shadow: var(--shadow-sm); border: 1px solid rgba(232,220,203,.7);
}
.card h2 {
  margin: 0 0 4px; font-size: 16px; color: var(--brown);
  display: flex; align-items: center; gap: 8px;
}
.card h2 .ico { font-size: 18px; }
.card .desc { font-size: 13px; color: var(--text-light); margin: 0 0 14px; }

/* 进度条 */
.progress-wrap { margin: 12px 0 6px; }
.progress {
  height: 10px; background: var(--cream-warm);
  border-radius: 999px; overflow: hidden;
}
.progress > i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--yellow), #FFC857);
  border-radius: 999px; transition: width .35s ease;
}
.progress-label {
  display: flex; justify-content: space-between;
  font-size: 12.5px; color: var(--text-light); margin-top: 6px;
}

/* 按钮 */
.btn {
  display: block; width: 100%;
  border: none; border-radius: 14px;
  padding: 15px 18px; font-size: 16px; font-weight: 700;
  cursor: pointer; text-align: center; font-family: inherit;
  transition: transform .1s ease, opacity .2s;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--brown); color: #fff; }
.btn.amber { background: var(--yellow); color: var(--brown-dark); }
.btn.outline {
  background: var(--white); color: var(--brown);
  border: 1.5px solid var(--line);
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* 文档列表 */
.doc-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 4px; border-bottom: 1px solid var(--cream-warm);
  cursor: pointer;
}
.doc-item:last-child { border-bottom: none; }
.doc-item .idx {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: var(--yellow-soft); color: var(--brown);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.doc-item .meta { flex: 1; min-width: 0; }
.doc-item .meta b { display: block; font-size: 14.5px; color: var(--text); font-weight: 600; }
.doc-item .meta small { color: var(--gray); font-size: 12px; }
.doc-item .arrow { color: var(--gray); flex: none; font-size: 18px; }

/* ---------- 学习页 ---------- */
.learn-head {
  background: var(--white); border-radius: var(--r);
  padding: 14px 16px; margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.learn-head .kicker { font-size: 12px; color: var(--gray); }
.learn-head h2 { margin: 2px 0 10px; font-size: 17px; color: var(--brown); }
.chapter-nav {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.chapter-nav::-webkit-scrollbar { display: none; }
.chapter-nav button {
  flex: none; border: 1px solid var(--line); background: var(--cream);
  color: var(--text-light); border-radius: 999px;
  padding: 7px 14px; font-size: 13px; cursor: pointer;
  font-family: inherit; white-space: nowrap; max-width: 60vw;
  overflow: hidden; text-overflow: ellipsis;
}
.chapter-nav button.on {
  background: var(--brown); color: #fff; border-color: var(--brown); font-weight: 600;
}
.chapter-nav button.read { border-color: var(--yellow); color: var(--brown); }
.chapter-nav button.read::after { content: " ✓"; color: var(--yellow); }

.article {
  background: var(--white); border-radius: var(--r);
  padding: 20px 18px; box-shadow: var(--shadow-sm);
  font-size: 15.5px; line-height: 1.78;
  word-break: break-word;
}
.article h3 { font-size: 17px; color: var(--brown); margin: 22px 0 10px; padding-left: 11px; border-left: 4px solid var(--yellow); }
.article h3:first-child { margin-top: 0; }
.article h4 { font-size: 15.5px; color: var(--brown-dark); margin: 18px 0 8px; }
.article h5 { font-size: 15px; color: var(--text); margin: 16px 0 6px; }
.article p { margin: 0 0 12px; }
.article strong { color: var(--brown-dark); font-weight: 700; }
.article code {
  background: var(--yellow-soft); color: var(--brown);
  padding: 1px 6px; border-radius: 5px;
  font-size: .92em; font-weight: 600;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.article ul, .article ol { margin: 0 0 12px; padding-left: 22px; }
.article li { margin-bottom: 6px; }
.article ul.sub { margin-top: 5px; margin-bottom: 2px; padding-left: 18px; }
.article ul.sub li { font-size: .95em; color: var(--text-light); }
.article hr { border: none; border-top: 1px solid var(--line); margin: 20px 0; }

/* 表格：横向可滚动，避免手机挤成一团 */
.tw { overflow-x: auto; margin: 14px 0; -webkit-overflow-scrolling: touch; border-radius: 10px; border: 1px solid var(--line); }
.article table { border-collapse: collapse; width: 100%; min-width: 400px; font-size: 13.5px; }
.article th {
  background: var(--brown); color: #fff; font-weight: 600;
  padding: 10px 12px; text-align: left; white-space: nowrap;
}
.article td { padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.article tbody tr:nth-child(even) { background: var(--cream); }

/* 提示框 */
.callout {
  border-radius: 10px; padding: 13px 15px; margin: 14px 0;
  border-left: 5px solid var(--yellow); background: var(--yellow-soft);
}
.callout .co-h { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.callout .co-tag {
  font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px;
  background: var(--yellow); color: var(--brown-dark);
}
.callout .co-title { font-weight: 700; font-size: 14.5px; color: var(--brown-dark); }
.callout p { margin: 0 0 6px; font-size: 14.5px; }
.callout p:last-child { margin-bottom: 0; }
.callout.co-warn { border-left-color: #E08A00; background: #FFF0D0; }
.callout.co-warn .co-tag { background: #E08A00; color: #fff; }
.callout.co-danger { border-left-color: var(--red-ink); background: var(--pink); }
.callout.co-danger .co-tag { background: var(--red-ink); color: #fff; }
.callout.co-danger .co-title { color: #7B241C; }
.callout.co-case { border-left-color: #2E7D6F; background: #E6F4F0; }
.callout.co-case .co-tag { background: #2E7D6F; color: #fff; }

.article figure { margin: 16px 0; }
.article figure img { width: 100%; border-radius: 10px; border: 1px solid var(--line); display: block; }
.article figcaption { font-size: 12.5px; color: var(--gray); text-align: center; margin-top: 7px; }
.img-missing {
  border: 1.5px dashed #D9B98A; background: var(--yellow-soft);
  border-radius: 10px; padding: 22px 14px; text-align: center; margin: 14px 0;
}
.img-missing span { color: #B07A2A; font-weight: 700; font-size: 13.5px; }
.img-missing em { display: block; color: var(--gray); font-size: 12.5px; font-style: normal; margin-top: 5px; }

.learn-actions { display: flex; gap: 10px; margin-top: 14px; }
.learn-actions .btn { flex: 1; padding: 13px; font-size: 15px; }

/* ---------- 答题页 ---------- */
.quiz-head {
  position: sticky; top: 56px; z-index: 40;
  background: var(--white); border-radius: var(--r);
  padding: 13px 16px; margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.quiz-head .row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text-light); margin-bottom: 8px; }
.quiz-head .row b { color: var(--brown); font-size: 15px; }
.quiz-head .timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--brown); }
.quiz-head .timer.warn { color: var(--red-ink); }

.q-card {
  background: var(--white); border-radius: var(--r);
  padding: 20px 18px; box-shadow: var(--shadow-sm);
}
.q-type {
  display: inline-block; font-size: 11.5px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px;
  background: var(--yellow-soft); color: var(--brown); margin-bottom: 10px;
}
.q-type.single { background: #E8F0FE; color: #1A56A8; }
.q-type.multiple { background: #E6F4F0; color: #1E5348; }
.q-type.judge { background: var(--yellow-soft); color: var(--brown); }
.q-stem { font-size: 16.5px; font-weight: 600; line-height: 1.7; margin-bottom: 16px; color: var(--text); }

.opts { margin-bottom: 4px; }

.opt {
  display: flex; align-items: flex-start; gap: 11px;
  border: 1.5px solid var(--line); border-radius: 12px;
  padding: 13px 14px; margin-bottom: 10px; cursor: pointer;
  background: var(--white); transition: all .15s ease;
  font-size: 15px; line-height: 1.6;
}
.opt:active { transform: scale(.99); }
.opt .mark {
  width: 24px; height: 24px; flex: none; border-radius: 7px;
  border: 2px solid var(--line); background: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--text-light);
  transition: all .15s ease; margin-top: 1px;
}
.opt.multi .mark { border-radius: 6px; }
.opt.sel { border-color: var(--yellow); background: var(--yellow-soft); }
.opt.sel .mark { background: var(--yellow); border-color: var(--yellow); color: var(--brown-dark); }
.opt.right { border-color: var(--green-ink); background: #EAF7EA; }
.opt.right .mark { background: var(--green-ink); border-color: var(--green-ink); color: #fff; }
.opt.wrong { border-color: var(--red-ink); background: var(--pink); }
.opt.wrong .mark { background: var(--red-ink); border-color: var(--red-ink); color: #fff; }
.opt.locked { cursor: default; }

.explain {
  margin-top: 14px; padding: 13px 15px; border-radius: 10px;
  background: var(--cream-warm); border-left: 4px solid var(--yellow);
  font-size: 14px; line-height: 1.7;
}
.explain b { color: var(--brown); }
.explain .link {
  display: inline-block; margin-top: 9px; color: var(--brown);
  font-weight: 700; text-decoration: underline; font-size: 13.5px; cursor: pointer;
}

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

/* ---------- 结果页 ---------- */
.result-hero {
  border-radius: var(--r-lg); padding: 30px 22px; text-align: center;
  margin-bottom: 16px; color: #fff;
}
.result-hero.pass { background: linear-gradient(150deg, #2E7D6F, #1E5348); }
.result-hero.fail { background: linear-gradient(150deg, #B4553F, #7B241C); }
.result-hero .big { font-size: 52px; font-weight: 800; line-height: 1.1; letter-spacing: -1px; }
.result-hero .big small { font-size: 20px; font-weight: 600; opacity: .8; }
.result-hero .verdict { font-size: 19px; font-weight: 700; margin-top: 8px; }
.result-hero .sub { font-size: 13.5px; opacity: .85; margin-top: 6px; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat {
  background: var(--white); border-radius: 12px; padding: 13px 8px;
  text-align: center; box-shadow: var(--shadow-sm);
}
.stat .n { font-size: 21px; font-weight: 800; color: var(--brown); }
.stat .l { font-size: 12px; color: var(--gray); margin-top: 2px; }

.wrong-item {
  background: var(--white); border-radius: 12px; padding: 15px;
  margin-bottom: 11px; box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--red-ink);
}
.wrong-item .q { font-size: 14.5px; font-weight: 600; margin-bottom: 9px; line-height: 1.6; }
.wrong-item .line { font-size: 13.5px; margin-bottom: 5px; color: var(--text-light); }
.wrong-item .line.mine { color: var(--red-ink); }
.wrong-item .line.right { color: var(--green-ink); }
.wrong-item .line b { font-weight: 700; }
.wrong-item .explain { margin-top: 10px; font-size: 13.5px; }

.submit-state {
  font-size: 12.5px; text-align: center; padding: 9px;
  border-radius: 9px; margin-top: 12px;
}
.submit-state.ok { background: #EAF7EA; color: var(--green-ink); }
.submit-state.pending { background: var(--yellow-soft); color: #8A6212; }
.submit-state.err { background: var(--pink); color: var(--red-ink); }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: flex; padding: 6px 0 calc(6px + var(--safe-b));
}
.tabbar button {
  flex: 1; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 0; color: var(--gray); font-size: 11.5px;
  font-family: inherit; font-weight: 600;
}
.tabbar button .i { font-size: 20px; line-height: 1; filter: grayscale(1); opacity: .55; }
.tabbar button.on { color: var(--brown); }
.tabbar button.on .i { filter: none; opacity: 1; }
.tabbar button:disabled { opacity: .35; }

/* ---------- 必填项 ---------- */
.req { color: var(--red-ink); font-weight: 700; }
input.input-err {
  border-color: var(--red-ink) !important;
  background: #FFF6F6 !important;
}

/* ---------- 通用 ---------- */
.muted { color: var(--gray); font-size: 13px; }
.center { text-align: center; }
.empty { text-align: center; padding: 40px 20px; color: var(--gray); }
.empty .i { font-size: 40px; display: block; margin-bottom: 10px; opacity: .5; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b));
  transform: translateX(-50%) translateY(16px);
  background: rgba(74,59,42,.95); color: #fff;
  padding: 11px 20px; border-radius: 999px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .25s ease;
  z-index: 100; max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.loading { text-align: center; padding: 50px 20px; color: var(--gray); }
.spinner {
  width: 30px; height: 30px; border: 3px solid var(--line);
  border-top-color: var(--yellow); border-radius: 50%;
  margin: 0 auto 14px; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 560px) {
  .article { padding: 26px 30px; }
  .hero h1 { font-size: 26px; }
}
