:root {
  --felt: #0f2a20;
  --felt-2: #173d2e;
  --gold: #c9a24b;
  --gold-ink: #7a5a12;
  --paper: #f6f1e4;
  --card: #fffdf7;
  --ink: #1d2420;
  --muted: #5f6b63;
  --line: #e2dac6;
  --good: #1f7a4c;
  --good-bg: #e3f3e8;
  --bad: #b3261e;
  --bad-bg: #fbe6e3;
  --banner-h: 0px; /* height of the app's bottom ad banner, set by ads.js */
  --serif: "Songti SC", "Noto Serif CJK SC", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.7 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--banner-h);
}

/* Static text is written in both languages; show the one that matches. */
html[data-lang="zh"] .en, html[data-lang="en"] .zh { display: none !important; }

a { color: var(--felt-2); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.3; margin: 0; text-wrap: balance; }
p { margin: 0 0 0.9em; }

/* ---------- header ---------- */
#hdr {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: var(--felt); color: #fff;
  border-bottom: 2px solid var(--gold);
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font: 700 17px var(--serif); white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--gold); color: var(--felt); font-size: 16px; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a { color: #d7e2dc; text-decoration: none; padding: 6px 12px; border-radius: 999px; font-size: 15px; white-space: nowrap; }
.nav a[aria-current="page"] { background: var(--gold); color: var(--felt); font-weight: 700; }
.lang { border: 1px solid #ffffff55; background: none; color: #fff; border-radius: 999px; padding: 5px 10px; font: 600 13px var(--sans); cursor: pointer; white-space: nowrap; }
@media (max-width: 480px) {
  .brand span:last-child { display: none; }
  .nav { margin-left: 0; flex: 1; justify-content: center; }
}

/* ---------- layout ---------- */
main { width: 100%; max-width: 760px; margin: 0 auto; padding: 20px 16px 40px; flex: 1; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 14px; }
.eyebrow { font: 700 12px var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold-ink); margin-bottom: 6px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 10px 20px; border-radius: 12px; border: 1px solid var(--felt);
  background: var(--felt); color: #fff; font: 700 16px var(--sans); text-decoration: none; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--felt); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--felt); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.linklike { border: 0; background: none; padding: 0; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; }

/* ---------- hero (index) ---------- */
.hero { background: var(--felt); color: #fff; border-radius: 18px; padding: 28px 22px; margin-bottom: 16px; border: 1px solid var(--felt-2); }
.hero .eyebrow { color: var(--gold); }
.hero h1 { font-size: clamp(26px, 6vw, 38px); margin-bottom: 10px; }
.hero p { color: #d7e2dc; margin-bottom: 0; }
.hero .btn { border-color: #ffffff66; }
.hero .btn.ghost { color: #fff; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.fact { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 10px; text-align: center; }
.fact b { display: block; font: 700 26px var(--serif); color: var(--felt-2); }
.fact span { font-size: 13px; color: var(--muted); line-height: 1.4; display: block; }
.card h2 { font-size: 20px; margin-bottom: 8px; }
.steps { margin: 0; padding-left: 1.3em; }
.steps li { margin-bottom: 6px; }

/* ---------- study ---------- */
.mod-list { display: grid; gap: 10px; }
.mod {
  display: flex; gap: 14px; align-items: center; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
}
.mod:hover { border-color: var(--gold); }
.mod-icon { font-size: 26px; width: 36px; text-align: center; flex: none; }
.mod-body { flex: 1; min-width: 0; }
.mod-body b { display: block; font: 700 17px var(--serif); }
.mod-body span { font-size: 14px; color: var(--muted); display: block; line-height: 1.5; }
.mod-done { flex: none; font-size: 13px; font-weight: 700; color: var(--good); background: var(--good-bg); border-radius: 999px; padding: 2px 10px; }
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 10px 0 4px; }
.progress i { display: block; height: 100%; background: var(--gold); border-radius: 999px; }

.reader h1 { font-size: clamp(24px, 5.5vw, 32px); margin-bottom: 6px; }
.reader h2 { font-size: 20px; margin: 26px 0 10px; padding-top: 18px; border-top: 1px solid var(--line); }
.reader ul { padding-left: 1.2em; margin: 0 0 1em; }
.reader li { margin-bottom: 6px; }
.note { background: #fbf3dc; border-left: 4px solid var(--gold); border-radius: 0 10px 10px 0; padding: 10px 14px; margin: 0 0 1em; font-size: 15px; }
.table-wrap { overflow-x: auto; margin: 0 0 1em; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #efe8d5; font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td { font-variant-numeric: tabular-nums; }
.back { display: inline-block; margin-bottom: 12px; font-size: 15px; text-decoration: none; }
.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
.pager a { flex: 1; text-decoration: none; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); font-size: 14px; color: var(--muted); min-width: 0; }
.pager a b { display: block; color: var(--ink); font-family: var(--serif); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager a.next { text-align: right; }
.sources { font-size: 14px; padding-left: 1.2em; margin: 0; }
.sources li { margin-bottom: 4px; overflow-wrap: anywhere; }

/* ---------- quiz ---------- */
.cat-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.cat { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; cursor: pointer; font: inherit; color: inherit; }
.cat:hover { border-color: var(--gold); }
.cat b { display: block; font: 700 16px var(--serif); }
.cat span { font-size: 13px; color: var(--muted); }
.q-meta { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--muted); }
.q-text { font: 700 19px/1.5 var(--serif); margin: 14px 0; }
.opts { display: grid; gap: 10px; }
.opt {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px;
  font: 16px/1.5 var(--sans); color: inherit; cursor: pointer; min-height: 48px;
}
.opt:hover:not(:disabled) { border-color: var(--gold); }
.opt:disabled { cursor: default; color: inherit; opacity: 1; }
.opt .key { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; font: 700 13px var(--sans); }
.opt.right { border-color: var(--good); background: var(--good-bg); }
.opt.right .key { background: var(--good); border-color: var(--good); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.wrong .key { background: var(--bad); border-color: var(--bad); color: #fff; }
.explain { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: #efe8d5; font-size: 15px; }
.explain b { display: block; margin-bottom: 2px; }
.score { text-align: center; padding: 26px 18px; }
.score .big { font: 700 56px/1 var(--serif); color: var(--felt-2); }
.score .verdict { font: 700 18px var(--serif); margin: 10px 0 4px; }
.score .verdict.pass { color: var(--good); }
.score .verdict.fail { color: var(--bad); }
.review-item { border-top: 1px solid var(--line); padding: 12px 0; font-size: 15px; }
.review-item:first-of-type { border-top: 0; }
.review-item b { display: block; margin-bottom: 4px; }
.review-item .ans { color: var(--good); }

/* ---------- ads ---------- */
.ad-slot { margin: 18px 0; min-height: 0; }
.in-app .ad-slot { display: none; }
.ad-slot.ad-preview { min-height: 90px; display: grid; place-items: center; border: 1px dashed #b9ae92; border-radius: 10px; color: #8a8067; font-size: 13px; }
.ad-slot.ad-preview::before { content: "Ad · 广告位（仅本地预览可见）"; }

/* ---------- footer ---------- */
#ftr { background: var(--felt); color: #b9c8c0; font-size: 13px; line-height: 1.6; padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px)); }
#ftr p { max-width: 760px; margin: 0 auto 8px; }
#ftr a, #ftr .linklike { color: #e7d7ab; }
.ftr-links { display: flex; flex-wrap: wrap; gap: 16px; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
