/* CitizenNow — one stylesheet, mobile first. */
:root {
  --bg: #f8fafd;
  --surface: #ffffff;
  --surface-2: #f5f7fb;
  --surface-3: #f0f4f9;
  --ink: #1f1f1f;
  --text: #30343b;
  --muted: #505863;
  --line: #dde3ea;
  --line-strong: #c4cbd4;
  --brand: #0b57d0;
  --action: #0b57d0;
  --action-hover: #0842a0;
  --brand-soft: #e8f0fe;
  --primary: #17345b;
  --primary-hover: #244b7c;
  --on-primary: #ffffff;
  --accent: #f2b84b;
  --accent-soft: #fdf3dc;
  --ok: #0f7b55;
  --ok-bg: #e5f5ed;
  --ok-line: #9fd8bf;
  --bad: #b93a0e;
  --bad-bg: #fdede4;
  --bad-line: #f3b79c;
  --info: #0b57d0;
  --info-bg: #e8f0fe;
  --shadow-sm: 0 1px 2px rgba(19, 37, 74, .06), 0 1px 1px rgba(19, 37, 74, .04);
  --shadow: 0 6px 24px -8px rgba(19, 37, 74, .18), 0 2px 6px rgba(19, 37, 74, .05);
  --shadow-lg: 0 24px 60px -20px rgba(19, 37, 74, .35);
  --r-sm: 10px;
  --r: 12px;
  --r-lg: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Noto Sans TC", sans-serif;
  --header-h: 68px;
  --tabbar-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #121b2d;
    --surface-2: #162036;
    --surface-3: #1b2840;
    --ink: #eaf0fb;
    --text: #dbe2ee;
    --muted: #9ba5b8;
    --line: #273044;
    --line-strong: #364159;
    --brand: #8db4ff;
    --brand-soft: #172647;
    --primary: #e3eaff;
    --primary-hover: #ffffff;
    --on-primary: #0e1626;
    --accent: #f5c56a;
    --accent-soft: #33290f;
    --ok: #4fd3a0;
    --ok-bg: #12291f;
    --ok-line: #1f5a43;
    --bad: #ff8a5c;
    --bad-bg: #331a10;
    --bad-line: #6b3218;
    --info: #8db4ff;
    --info-bg: #17223a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 8px 28px -10px rgba(0, 0, 0, .6);
    --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
@media (min-width: 1150px) { body { padding-bottom: 0; } }
img, svg { max-width: 100%; }
a { color: var(--info); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 4.5vw, 2.6rem); font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: clamp(1.3rem, 3vw, 1.7rem); font-weight: 800; }
h3 { font-size: 1.1rem; font-weight: 700; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 8px; top: 8px; background: var(--surface); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:not(:focus) { clip-path: inset(50%); }

.wrap { width: 100%; max-width: 1600px; margin: 0 auto; padding: 0 clamp(16px, 3.3vw, 48px); }
.wrap-narrow { max-width: 820px; }
.section { padding: 40px 0; }
.section-sm { padding: 24px 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.tiny { font-size: .78rem; }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.kicker { font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); margin-bottom: 8px; }
.lead { font-size: 1.12rem; color: var(--muted); }
.icon { width: 1.15em; height: 1.15em; vertical-align: -.2em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Buttons, chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 6px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none;
  background: var(--primary); color: var(--on-primary); transition: transform .08s ease, background .15s ease, border-color .15s ease;
  -webkit-tap-highlight-color: transparent; text-align: center;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }
.btn-brand { background: var(--action); color: #fff; }
.btn-brand:hover { background: var(--action-hover); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--muted); }
.btn-soft { background: var(--surface-3); color: var(--ink); }
.btn-soft:hover { background: var(--line); box-shadow: none; }
.btn-lg { min-height: 52px; padding: 0 22px; font-size: 1rem; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: .9rem; }
.btn-block { width: 100%; white-space: normal; text-align: center; }
.btn-link { background: none; border: 0; color: var(--info); font: inherit; cursor: pointer; padding: 6px 2px; font-weight: 600; }
.btn-link:hover { text-decoration: underline; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: .8rem; font-weight: 700; background: var(--surface-3); color: var(--ink); line-height: 1.4;
}
.chip-brand { background: var(--brand-soft); color: var(--brand); }
.chip-ok { background: var(--ok-bg); color: var(--ok); }
.chip-bad { background: var(--bad-bg); color: var(--bad); }
.chip-gold { background: var(--accent-soft); color: #8a5a00; }
@media (prefers-color-scheme: dark) { .chip-gold { color: var(--accent); } }
.chip-info { background: var(--info-bg); color: var(--info); }
/* Difficulty level: 1–3 filled bars, like a signal meter */
.chip-level.lv1 { background: var(--ok-bg); color: var(--ok); }
.chip-level.lv2 { background: var(--accent-soft); color: #8a5a00; }
.chip-level.lv3 { background: var(--bad-bg); color: var(--bad); }
@media (prefers-color-scheme: dark) { .chip-level.lv2 { color: var(--accent); } }
.lv-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 10px; }
.lv-bars b { width: 3px; border-radius: 1px; background: currentColor; opacity: .28; }
.lv-bars b:nth-child(1) { height: 4px; } .lv-bars b:nth-child(2) { height: 7px; } .lv-bars b:nth-child(3) { height: 10px; }
.lv1 .lv-bars b:nth-child(1), .lv2 .lv-bars b:nth-child(-n+2), .lv3 .lv-bars b { opacity: 1; }
.ri-q + .chip-level { margin-left: 6px; vertical-align: 1px; padding: 1px 8px; font-size: .72rem; }
.level-cards .card { display: flex; flex-direction: column; gap: 8px; }
.level-cards .card p { margin: 0; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40; height: var(--header-h);
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.site-header .wrap { height: 100%; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 1.12rem; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: var(--action); display: grid; place-items: center; }
.brand-mark svg { width: 22px; height: 22px; fill: #fff; }
.brand small { font-weight: 600; color: var(--muted); font-size: .72rem; display: block; letter-spacing: 0; margin-top: -3px; }
.nav { display: none; gap: 2px; margin-inline-start: auto; }
.nav a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: .95rem; padding: 8px 9px; border-radius: 6px; white-space: nowrap; }
@media (max-width: 1199px) { .brand small { display: none; } }
@media (max-width: 360px) { .site-header .wrap { gap: 8px; } .brand { gap: 6px; } .language-menu summary { padding-inline: 8px; } }
.nav a:hover { background: var(--surface-3); }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); }
.header-tools { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.language-menu { position: relative; }
.language-menu summary { cursor: pointer; list-style: none; }
.language-menu summary::-webkit-details-marker { display: none; }
.language-menu ul {
  position: absolute; inset-block-start: calc(100% + 8px); inset-inline-end: 0;
  width: max-content; min-width: 9rem; max-height: min(70vh, 25rem); overflow-y: auto;
  padding: 4px; margin: 0; list-style: none; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--shadow);
}
.language-menu a { display: block; padding: 8px 12px; border-radius: 6px; text-decoration: none; color: var(--ink); }
.language-menu a:hover, .language-menu a[aria-current="true"] { background: var(--brand-soft); color: var(--brand); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: var(--bg); display: grid; place-items: center; font-weight: 800; font-size: .9rem; overflow: hidden; text-decoration: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.pro-badge { font-size: .68rem; font-weight: 800; background: var(--accent); color: #3d2a00; padding: 2px 7px; border-radius: 999px; letter-spacing: .04em; }
.header-signin { display: none; }
@media (min-width: 1150px) {
  :root { --header-h: 76px; }
  .nav { display: flex; flex-wrap: wrap; justify-content: flex-end; }
  .nav a { padding: 6px 9px; }
  .header-tools { margin-inline-start: 0; }
  .header-signin { display: inline-flex; }
}

@media (min-width: 1150px) and (max-width: 1279px) { .nav a { padding-inline: 6px; font-size: .875rem; } }

/* Bottom tab bar (phones) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--muted); font-size: .7rem; font-weight: 700; }
.tabbar a .icon { width: 23px; height: 23px; }
.tabbar a[aria-current="page"] { color: var(--brand); }
@media (min-width: 1150px) { .tabbar { display: none; } }
body.focus-mode .tabbar { display: none; }
body.focus-mode { padding-bottom: 0; }

/* ---------- Footer ---------- */
.site-footer { background: var(--surface-3); border-top: 1px solid var(--line); margin-top: 48px; padding: 32px 0 40px; color: var(--muted); font-size: .88rem; }
.site-footer .cols { display: grid; gap: 24px; grid-template-columns: 1fr; }
.site-footer h4 { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink); margin-bottom: 8px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin: 6px 0; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--ink); }
.disclaimer { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin-bottom: 24px; line-height: 1.6; }
@media (min-width: 760px) { .site-footer .cols { grid-template-columns: 2fr 1fr 1fr 1fr; } }
.cluster-nav { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.cluster-nav summary { cursor: pointer; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink); font-weight: 700; }
.cluster-nav ul { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; }
.cluster-nav li { margin: 0; }
.cluster-nav [aria-current] { color: var(--ink); font-weight: 700; }
.next-steps { margin-top: 24px; }
.next-steps h3 { margin-bottom: 12px; }
.next-steps .card-link { display: flex; flex-direction: column; gap: 6px; }
.next-steps .kicker { margin: 0; }
.next-steps .tiny { margin-top: 10px; }
.journey { margin-bottom: 20px; }
.journey-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.journey-head h3 { margin: 0; }
.journey-bar { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; list-style: none; padding: 0; margin: 0 0 8px; }
.journey-bar li { height: 8px; border-radius: 4px; background: var(--line); }
.journey-bar li.done { background: var(--brand); opacity: .45; }
.journey-bar li.current { background: var(--brand); }
.journey-steps { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .journey-steps { grid-template-columns: 1fr 1.4fr; } }
.journey-next { border-color: var(--brand); }
.journey-next-group { display: grid; gap: 12px; }
.next-steps-also { font-size: 1rem; margin: 0 0 10px; }

/* ---------- Cards, grids ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.card-lg { padding: 28px; border-radius: var(--r-lg); }
.card h3 { margin-bottom: 6px; }
.card-link { display: block; text-decoration: none; color: inherit; transition: transform .12s ease, box-shadow .15s ease, border-color .15s; }
.card-link:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-strong); text-decoration: none; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .grid-2 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } .grid-4 { grid-template-columns: repeat(4, 1fr); } }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.notice { border-radius: var(--r); padding: 14px 16px; background: var(--info-bg); color: var(--text); border: 1px solid color-mix(in srgb, var(--info) 25%, transparent); }
.notice-gold { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.notice-ok { background: var(--ok-bg); border-color: var(--ok-line); }
.notice-bad { background: var(--bad-bg); border-color: var(--bad-line); }
.notice strong { color: var(--ink); }

/* ---------- Homepage ---------- */
.hero { padding: 44px 0 40px; }
.hero .wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; }
.hero-kicker { display: flex; gap: 8px; align-items: center; }
.hero-kicker::before { content: ""; width: 6px; height: 6px; flex: none; border-radius: 50%; background: currentColor; }
.hero h1 { font-size: clamp(2.25rem, 4.3vw, 4rem); font-weight: 700; line-height: 1.1; letter-spacing: -.045em; margin: 16px 0 20px; overflow-wrap: anywhere; }
@media (max-width: 360px) { .hero h1 { font-size: 2rem; } }
.hero h1 em { font-style: normal; color: var(--brand); }
.hero .lead { max-width: 64ch; line-height: 1.75; }
.hero-ctas { display: flex; gap: 10px; flex-wrap: wrap; margin: 24px 0 18px; }
.hero-note { display: flex; gap: 8px 16px; flex-wrap: wrap; color: var(--muted); font-size: .85rem; }
.hero-note span { display: inline-flex; align-items: center; gap: 6px; }
.hero-note .icon { color: var(--ok); }

.hero-card { align-self: center; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; }
.hero-card-head, .hero-card-body, .hero-card-foot { padding: 16px clamp(14px, 2vw, 24px); }
.hero-card-head, .hero-card-foot { background: var(--surface-3); }
.hero-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--line); }
.hero-card-head h2 { font-size: 1rem; margin: 0 0 2px; }
.hero-card-head p, .hero-card-foot { font-size: .82rem; color: var(--muted); margin: 0; }
.hero-card-head .chip { white-space: nowrap; }
.hero-card .q { font-weight: 700; color: var(--ink); font-size: 1.05rem; margin: 0 0 14px; }
.hero-card .options { gap: 8px; }
.hero-card .opt { min-height: 44px; padding: 8px 10px; gap: 8px; border-radius: 6px; font-size: .9rem; pointer-events: none; }
.hero-card .opt .mark { font-size: .75rem; }
.hero-card-foot { border-top: 1px solid var(--line); padding-block: 10px; }
@media (min-width: 960px) {
  .hero { padding: 80px 0 64px; }
  .hero .wrap { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: center; gap: clamp(32px, 4.5vw, 64px); }
}

.home-facts { padding: 0; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-block: 1px solid var(--line); }
.fact { padding: 16px; }
.fact:nth-child(odd) { border-right: 1px solid var(--line); }
.fact:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
.fact b { display: block; font-size: 1.7rem; font-weight: 650; color: var(--brand); letter-spacing: -.025em; line-height: 1.2; }
.fact span { color: var(--muted); font-size: .88rem; }
.home-facts .notice { margin: 16px 0 0; }
.home-section { padding: 48px 0; }
@media (max-width: 479px) { .home-section .grid-4 { grid-template-columns: minmax(0, 1fr); } }
.home-section-alt { background: var(--surface-3); border-block: 1px solid var(--line); }
.home-section .section-head h2 { font-size: clamp(1.55rem, 2.8vw, 2.35rem); font-weight: 700; }
.home-cta { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 22%, var(--line)); }
.home-cta p { color: var(--muted); }
@media (min-width: 760px) {
  .facts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .fact:nth-child(n) { border-bottom: 0; border-right: 1px solid var(--line); padding: 22px; }
  .fact:first-child { padding-left: 0; }
  .fact:last-child { border-right: 0; }
  .home-section { padding: 64px 0; }
}

/* ---------- Tiers ---------- */
.tier { position: relative; display: flex; flex-direction: column; }
.tier .price { font-size: 2rem; font-weight: 800; color: var(--ink); letter-spacing: -.02em; }
.tier .price small { font-size: .9rem; font-weight: 600; color: var(--muted); }
.tier ul { list-style: none; padding: 0; margin: 14px 0 20px; flex: 1; }
.tier li { display: flex; gap: 10px; padding: 6px 0; align-items: flex-start; }
.tier li .icon { color: var(--ok); margin-top: 3px; }
.tier-featured { border-color: var(--brand); }
.tier-featured::before { content: attr(data-badge); position: absolute; top: -12px; left: 20px; background: var(--action); color: #fff; font-size: .75rem; font-weight: 800; padding: 3px 10px; border-radius: 999px; }
.math { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; font-variant-numeric: tabular-nums; }
.math .total { border-top: 1px solid var(--line); padding-top: 6px; font-weight: 800; color: var(--ink); }

/* ---------- Test grid ---------- */
.sets { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 10px; }
.set-tile {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; min-height: 96px; padding: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); text-decoration: none; color: var(--ink);
  transition: transform .1s ease, box-shadow .15s ease, border-color .15s;
}
.set-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; border-color: var(--line-strong); }
.set-tile .n { font-size: 1.55rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.set-tile .lbl { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.set-tile .st { font-size: .78rem; font-weight: 700; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.set-tile .bar { position: absolute; left: 12px; right: 12px; bottom: 8px; height: 3px; border-radius: 3px; background: var(--surface-3); overflow: hidden; display: none; }
.set-tile .bar i { display: block; height: 100%; background: var(--info); }
.set-tile.in-progress .bar { display: block; }
.set-tile.in-progress .st { visibility: hidden; }
.set-tile.done { border-color: var(--ok-line); background: linear-gradient(180deg, var(--surface), var(--ok-bg)); }
.set-tile.done .st { color: var(--ok); }
.set-tile.done.low { border-color: var(--bad-line); background: linear-gradient(180deg, var(--surface), var(--bad-bg)); }
.set-tile.done.low .st { color: var(--bad); }
.set-tile.locked { background: var(--surface-2); color: var(--muted); }
.set-tile.locked .n { color: var(--muted); }
.set-tile .lock { position: absolute; top: 10px; right: 10px; color: var(--muted); }
.set-tile.tier-member .lock { color: var(--info); }
.set-tile.tier-paid .lock { color: #b07a00; }
.set-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin-top: 12px; }
.set-legend span { display: inline-flex; gap: 6px; align-items: center; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ---------- Chapter cards ---------- */
.chapter-card { display: flex; gap: 14px; align-items: flex-start; }
.chapter-no {
  flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 1.05rem;
  background: var(--ink); color: var(--bg);
}
.chapter-card h3 { font-size: 1.02rem; margin: 0 0 2px; }
.chapter-card p { margin: 0; font-size: .88rem; color: var(--muted); }
.meter { height: 6px; background: var(--surface-3); border-radius: 6px; overflow: hidden; margin-top: 10px; }
.meter i { display: block; height: 100%; width: 0; border-radius: 6px; background: var(--ok); transition: width .5s ease; }
.meter.warn i { background: var(--accent); }
.meter.bad i { background: var(--bad); }

/* ---------- Prose ---------- */
.prose { font-size: 1.04rem; line-height: 1.8; }
.prose h2 { font-size: 1.35rem; margin-top: 1.8em; }
.prose h3 { margin-top: 1.4em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: .35em 0; }
.prose strong { color: var(--ink); }
.prose table { width: 100%; border-collapse: collapse; margin: 1.2em 0; font-size: .95rem; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { background: var(--surface-3); color: var(--ink); font-weight: 700; white-space: nowrap; }
.prose tr:nth-child(even) td { background: var(--surface-2); }
.article-head { padding: 28px 0 8px; }
.breadcrumbs { font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--ink); }
.toc { position: sticky; top: calc(var(--header-h) + 16px); }
.article-layout { display: grid; gap: 28px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px) { .article-layout { grid-template-columns: minmax(0, 1fr) 300px; } }

/* ---------- Quiz ---------- */
.quiz-page { padding: 16px 0 40px; }
.quiz-shell { max-width: 720px; margin: 0 auto; }
.quiz-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.quiz-top .title { font-weight: 800; color: var(--ink); font-size: 1rem; line-height: 1.2; }
h1.title { margin: 0; letter-spacing: normal; }
.quiz-top .sub { font-size: .82rem; color: var(--muted); }
.quiz-top .exit { margin-inline-start: auto; }
[dir="rtl"] :is(.quiz-top a, .quiz-actions) .icon { transform: scaleX(-1); }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; display: inline-grid; place-items: center; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; flex: none;
}
.icon-btn:hover { border-color: var(--ink); }
.icon-btn.on { background: var(--accent-soft); border-color: var(--accent); color: #8a5a00; }
.progress { height: 8px; border-radius: 8px; background: var(--surface-3); overflow: hidden; display: flex; gap: 2px; margin-bottom: 18px; }
.progress i { flex: 1; background: transparent; }
.progress i.ok { background: var(--ok); }
.progress i.bad { background: var(--bad); }
.progress i.cur { background: var(--line-strong); }
.progress i.ans { background: var(--info); }
.qcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px 18px; box-shadow: var(--shadow); }
@media (min-width: 640px) { .qcard { padding: 30px; } }
.qmeta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.qnum { font-weight: 800; color: var(--muted); font-size: .85rem; letter-spacing: .02em; }
.qtext { font-size: clamp(1.15rem, 3.4vw, 1.4rem); font-weight: 700; color: var(--ink); line-height: 1.45; margin: 0 0 18px; }
.terms { display: flex; gap: 6px; flex-wrap: wrap; margin: -6px 0 16px; }
.terms span { font-size: .82rem; background: var(--info-bg); color: var(--info); padding: 3px 9px; border-radius: 8px; }
.terms span b { font-weight: 700; color: var(--ink); margin-right: 4px; }
.options { display: grid; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 12px 14px; text-align: start;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm); font: inherit; font-size: 1.02rem;
  color: var(--text); cursor: pointer; transition: border-color .12s, background .12s, transform .06s; -webkit-tap-highlight-color: transparent;
}
.opt:not(.locked):hover { border-color: var(--ink); background: var(--surface-2); }
.opt:not(.locked):active { transform: scale(.995); }
.opt .key {
  flex: none; min-width: 1.25em; font-weight: 700; font-size: .9rem; color: var(--muted);
}
.opt .txt { flex: 1; line-height: 1.45; }
.opt .mark { flex: none; display: none; align-items: center; gap: 4px; font-size: .8rem; font-weight: 800; }
.opt.selected { border-color: var(--info); background: var(--info-bg); }
.opt.selected .key { color: var(--info); }
.opt.correct { border-color: var(--ok); background: var(--ok-bg); }
.opt.correct .key { color: var(--ok); }
.opt.correct .mark { display: inline-flex; color: var(--ok); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.wrong .key { color: var(--bad); }
.opt.wrong .mark { display: inline-flex; color: var(--bad); }
.opt.locked { cursor: default; }
.opt.locked:not(.correct):not(.wrong) { opacity: .62; }
.options.tf { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.feedback { margin-top: 18px; border-radius: 16px; padding: 16px; border: 1px solid var(--line); background: var(--surface-2); animation: rise .2s ease; }
.feedback.ok { background: var(--ok-bg); border-color: var(--ok-line); }
.feedback.bad { background: var(--bad-bg); border-color: var(--bad-line); }
.feedback .verdict { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.02rem; margin-bottom: 8px; }
.feedback.ok .verdict { color: var(--ok); }
.feedback.bad .verdict { color: var(--bad); }
.feedback .exp { line-height: 1.7; }
.feedback .exp p { margin: 0 0 8px; }
.feedback .exp .lang-tag { font-size: .7rem; font-weight: 800; color: var(--muted); letter-spacing: .06em; display: block; margin-bottom: 2px; }
.feedback .src { font-size: .82rem; color: var(--muted); margin-top: 6px; display: flex; gap: 6px; align-items: center; }
.seg { display: inline-flex; background: color-mix(in srgb, var(--surface) 70%, transparent); border: 1px solid var(--line); border-radius: 999px; padding: 3px; margin-bottom: 10px; flex-wrap: wrap; }
.seg button { border: 0; background: none; font: inherit; font-size: .8rem; font-weight: 700; color: var(--muted); padding: 5px 11px; border-radius: 999px; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg button .icon { width: 12px; height: 12px; }
.explanation-language {
  max-width: 100%; margin-bottom: 10px; padding: 7px 10px; border-radius: 6px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); font: inherit; font-size: .875rem;
}
.quiz-actions { display: flex; gap: 10px; margin-top: 18px; align-items: center; }
.quiz-actions .btn-primary-next { margin-inline-start: auto; }
@media (max-width: 1023px) {
  .quiz-actions.sticky {
    position: sticky; bottom: 0; margin: 18px -16px -40px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  }
  .quiz-actions.sticky .btn-primary-next { flex: 1; }
}
.report-box { margin-top: 12px; }
.report-box textarea { width: 100%; min-height: 80px; border-radius: 12px; border: 1px solid var(--line-strong); padding: 10px; font: inherit; background: var(--surface); color: var(--text); }
.kbd-hint { font-size: .76rem; color: var(--muted); text-align: center; margin-top: 14px; display: none; }
@media (hover: hover) and (min-width: 1024px) { .kbd-hint { display: block; } }
kbd { font-family: inherit; font-size: .75rem; background: var(--surface); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.9); opacity: 0; } 60% { transform: scale(1.03); } 100% { transform: none; opacity: 1; } }

/* Summary / results */
.result-hero { text-align: center; padding: 26px 18px 22px; }
.ring { width: 168px; height: 168px; margin: 0 auto 12px; position: relative; animation: pop .45s ease; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 12; }
.ring .track { stroke: var(--surface-3); }
.ring .val { stroke: var(--ok); stroke-linecap: round; transition: stroke-dashoffset 1s ease; }
.ring.fail .val { stroke: var(--bad); }
.ring .ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .ring-label b { font-size: 2.6rem; font-weight: 800; color: var(--ink); letter-spacing: -.03em; line-height: 1; display: block; }
.ring .ring-label span { font-size: .85rem; color: var(--muted); font-weight: 700; }
.verdict-badge { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px; font-weight: 800; font-size: 1rem; }
.verdict-badge.pass { background: var(--ok-bg); color: var(--ok); }
.verdict-badge.fail { background: var(--bad-bg); color: var(--bad); }
.chapter-bars { display: grid; gap: 12px; }
.cbar .head { display: flex; justify-content: space-between; gap: 10px; font-size: .92rem; margin-bottom: 4px; }
.cbar .head b { color: var(--ink); font-weight: 700; }
.cbar .head span { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.review-list { display: grid; gap: 10px; }
.review-item { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.review-item summary { list-style: none; cursor: pointer; padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; }
.review-item summary::-webkit-details-marker { display: none; }
.review-item .ri-mark { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; }
.review-item.ok .ri-mark { background: var(--ok-bg); color: var(--ok); }
.review-item.bad .ri-mark { background: var(--bad-bg); color: var(--bad); }
.review-item .ri-q { font-weight: 600; color: var(--ink); }
.review-item .ri-body { padding: 0 16px 16px 54px; font-size: .95rem; }
.review-item .ri-body .ans { margin: 4px 0; }
.review-item .ri-body .ans.ok { color: var(--ok); font-weight: 700; }
.review-item .ri-body .ans.bad { color: var(--bad); font-weight: 700; text-decoration: line-through; }

/* Mock exam */
.mock-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.timer { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.05rem; padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.timer.warn { background: var(--accent-soft); border-color: var(--accent); }
.timer.danger { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .65; } }
.palette { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; margin: 16px 0 4px; }
.palette button {
  aspect-ratio: 1; border-radius: 9px; border: 1.5px solid var(--line-strong); background: var(--surface); font: inherit; font-size: .82rem;
  font-weight: 800; color: var(--muted); cursor: pointer; position: relative; padding: 0;
}
.palette button.ans { background: var(--info-bg); border-color: var(--info); color: var(--info); }
.palette button.cur { border-color: var(--ink); color: var(--ink); box-shadow: 0 0 0 2px var(--ink) inset; }
.palette button.flag::after { content: ""; position: absolute; top: -3px; right: -3px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.mock-intro { max-width: 640px; margin: 0 auto; }
.rules { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 10px; }
.rules li { display: flex; gap: 12px; align-items: flex-start; background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.rules li .icon { color: var(--brand); margin-top: 3px; }
.paper-list { display: grid; gap: 10px; }
.paper { display: flex; gap: 14px; align-items: center; }
.paper .pn { width: 48px; height: 48px; border-radius: 14px; background: var(--surface-3); display: grid; place-items: center; font-weight: 800; color: var(--ink); flex: none; }
.paper .best { margin-left: auto; text-align: right; font-size: .85rem; color: var(--muted); }

/* Gate card (sign-in / pricing prompts shown inline, never as pop-ups) */
.gate { text-align: center; padding: 30px 22px; border-radius: var(--r-lg); background: linear-gradient(160deg, var(--surface), var(--surface-2)); border: 1px solid var(--line); }
.gate .gate-icon { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; margin: 0 auto 12px; background: var(--info-bg); color: var(--info); }
.gate.gold .gate-icon { background: var(--accent-soft); color: #8a5a00; }
.gate .gate-icon .icon { width: 28px; height: 28px; }
.gate ul { text-align: left; display: inline-grid; gap: 6px; margin: 6px 0 18px; padding-left: 1.2em; }
.google-btn { background: #fff; color: #1f1f1f; border: 1px solid #dadce0; }
.google-btn:hover { background: #f8f9fa; color: #1f1f1f; }
.google-btn svg { width: 20px; height: 20px; }

/* Flashcards */
.deck-tabs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 18px; }
.flip-wrap { perspective: 1400px; max-width: 520px; margin: 0 auto; }
.flip { position: relative; width: 100%; aspect-ratio: 4 / 3; cursor: pointer; transform-style: preserve-3d; transition: transform .5s cubic-bezier(.2, .8, .2, 1); }
.flip.flipped { transform: rotateY(180deg); }
.flip .face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: var(--r-lg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 26px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
}
.flip .front { background: linear-gradient(150deg, var(--ink), color-mix(in srgb, var(--ink) 75%, var(--brand))); color: #fff; border: 0; }
@media (prefers-color-scheme: dark) { .flip .front { background: linear-gradient(150deg, #23345e, #172647); } }
.flip .front .big { font-size: clamp(1.6rem, 6vw, 2.4rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.flip .front .hint { position: absolute; bottom: 16px; font-size: .8rem; opacity: .7; }
.flip .back { transform: rotateY(180deg); overflow-y: auto; }
.flip .back .en { font-size: 1.08rem; font-weight: 600; color: var(--ink); line-height: 1.5; }
.flip .back .zh { margin-top: 12px; color: var(--muted); line-height: 1.7; }
.deck-nav { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 20px; }
.deck-count { font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 70px; text-align: center; }

/* Progress page */
.gauge { position: relative; width: 220px; margin: 0 auto; }
.gauge svg { width: 100%; }
.gauge .g-label { position: absolute; left: 0; right: 0; bottom: 6px; text-align: center; }
.gauge .g-label b { font-size: 3rem; font-weight: 800; color: var(--ink); letter-spacing: -.03em; line-height: 1; }
.history { width: 100%; border-collapse: collapse; font-size: .92rem; }
.history td, .history th { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.history th { color: var(--muted); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.spark { display: flex; align-items: flex-end; gap: 4px; height: 64px; }
.spark i { flex: 1; background: var(--info); border-radius: 4px 4px 0 0; min-height: 4px; opacity: .85; }
.spark i.pass { background: var(--ok); }
.spark i.fail { background: var(--bad); }

/* Tables and forms (account, admin) */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { background: var(--surface-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 700; font-size: .9rem; color: var(--ink); }
.field .hint { font-size: .82rem; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font: inherit;
}
textarea.input { min-height: 90px; }
.input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 14%, transparent); }
.check { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.check input { width: 20px; height: 20px; accent-color: var(--ink); }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.kpi b { display: block; font-size: 1.6rem; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi span { font-size: .82rem; color: var(--muted); }
.kpi .meter { margin-top: 8px; }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.admin-nav { display: flex; gap: 6px; flex-wrap: wrap; margin: 18px 0; }
.admin-nav a { padding: 7px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 600; font-size: .9rem; }
.admin-nav a[aria-current="page"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* FAQ */
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; list-style: none; padding: 16px 0; font-weight: 700; color: var(--ink); display: flex; justify-content: space-between; gap: 12px; overflow-wrap: anywhere; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.4rem; line-height: 1; color: var(--muted); transition: transform .2s; flex: none; }
.faq details[open] summary::after { content: "\2212"; } /* minus sign; a rotated "+" overflowed narrow screens */
.faq details > div { padding: 0 0 16px; color: var(--muted); }

/* Step list */
.steps { counter-reset: s; display: grid; gap: 14px; }
.steps > div { position: relative; padding-left: 52px; }
.steps > div::before { counter-increment: s; content: counter(s); position: absolute; left: 0; top: 0; width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 800; display: grid; place-items: center; }

/* Cheat sheet (printable) */
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 24px; }
.sheet h2 { font-size: 1.1rem; border-bottom: 2px solid var(--ink); padding-bottom: 6px; margin-top: 18px; }
.sheet table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.sheet td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.sheet td:first-child { font-weight: 800; color: var(--ink); white-space: nowrap; width: 1%; }
.sheet td .zh { color: var(--muted); font-size: .85rem; display: block; }
.sheet-locked { position: relative; max-height: 360px; overflow: hidden; }
.sheet-locked::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 200px; background: linear-gradient(transparent, var(--surface)); }

@media print {
  body { background: #fff; color: #000; padding: 0; font-size: 11pt; }
  .site-header, .tabbar, .site-footer, .no-print, .breadcrumbs { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .sheet { border: 0; padding: 0; box-shadow: none; }
  .sheet-cols { columns: 2; column-gap: 24px; }
  .sheet h2 { break-after: avoid; color: #000; }
  .sheet tr { break-inside: avoid; }
  a { color: #000; text-decoration: none; }
}

/* Toast (non-blocking status line) */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 18px); transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 700; font-size: .9rem; opacity: 0; transition: .25s ease; z-index: 80; pointer-events: none; box-shadow: var(--shadow-lg); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (min-width: 1150px) { .toast { bottom: 28px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
