:root {
  --navy: #0b1f3a;
  --navy-2: #132a4d;
  --navy-3: #1c3b66;
  --gold: #d4a017;
  --gold-2: #f3e6c0;
  --paper: #f7f4ef;
  --ink: #1a1a1a;
  --muted: #5c5a56;
  --ok: #1f7a45;
  --ok-bg: #e5f6eb;
  --bad: #b3261e;
  --bad-bg: #fdecea;
  --lock: #8a8376;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(11, 31, 58, 0.12);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--paper); color: var(--ink); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: "Noto Sans CJK HK", "Noto Sans TC", "PingFang HK", "PingFang TC",
    "Microsoft JhengHei", system-ui, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
  min-height: 100dvh;
}
#app { max-width: 760px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--navy); color: var(--gold-2); padding: 12px 16px;
  position: sticky; top: 0; z-index: 10;
}
.brand { color: var(--gold-2); text-decoration: none; font-weight: 800; letter-spacing: 0.02em; }
.lang-switch select {
  background: var(--navy-2); color: var(--gold-2); border: 1px solid #d4a01766;
  border-radius: 8px; padding: 6px 8px; font-size: 16px; /* ≥16px avoids iOS Safari focus zoom */
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
#main { flex: 1; padding: 18px 16px 40px; }
.site-footer { padding: 16px; color: var(--muted); font-size: 0.78rem; }
h1 { font-size: 1.45rem; margin: 0 0 8px; color: var(--navy); }
h2 { font-size: 1.15rem; margin: 0 0 8px; }
.lead { color: var(--muted); margin: 0 0 18px; }
.hero {
  background: linear-gradient(160deg, var(--navy), var(--navy-3));
  color: var(--gold-2); border-radius: 18px; padding: 22px 20px; margin-bottom: 18px;
}
.hero h1 { color: var(--gold-2); }
.hero .lead { color: #d7d0c4; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .grid { grid-template-columns: 1fr; } }
.card {
  background: #fff; border-radius: var(--radius); padding: 14px 14px 12px;
  box-shadow: var(--shadow); border: 1px solid #ece7dd; text-align: left;
}
.card h3 { margin: 0 0 4px; font-size: 1.05rem; }
.card p { margin: 0; color: var(--muted); font-size: 0.9rem; }
a.card, button.card {
  display: block; width: 100%; cursor: pointer; font: inherit; color: inherit; text-decoration: none;
}
a.card:hover, button.card:hover { border-color: var(--gold); }
.badge {
  display: inline-block; font-size: 0.72rem; font-weight: 700; border-radius: 999px;
  padding: 2px 8px; margin-left: 6px; vertical-align: middle;
}
.badge.free { background: var(--ok-bg); color: var(--ok); }
.badge.lock { background: #eee; color: var(--lock); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; font-size: 1rem;
  cursor: pointer; font-family: inherit; text-decoration: none;
}
.btn-primary { background: var(--gold); color: var(--navy); width: 100%; }
.btn-navy { background: var(--navy); color: var(--gold-2); width: 100%; }
.btn-ghost { background: transparent; color: var(--navy); border: 1px solid #cfc8ba; width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex; gap: 10px; align-items: flex-start; width: 100%;
  background: #fff; border: 2px solid #e4ddd0; border-radius: 12px;
  padding: 12px; text-align: left; font: inherit; cursor: pointer;
}
.option.selected { border-color: var(--gold); background: #fff8e6; }
.option.correct { border-color: var(--ok); background: var(--ok-bg); }
.option.wrong { border-color: var(--bad); background: var(--bad-bg); }
.option input { margin-top: 3px; }
.progress { color: var(--muted); font-size: 0.9rem; margin-bottom: 8px; }
.q-stem { font-size: 1.12rem; font-weight: 700; margin: 0 0 14px; }
.feedback { border-radius: 12px; padding: 14px; margin-top: 12px; }
.feedback.ok { background: var(--ok-bg); }
.feedback.bad { background: var(--bad-bg); }
.feedback h3 { margin-top: 0; }
.feedback h4 { margin: 12px 0 4px; font-size: 0.95rem; }
.price { font-size: 2rem; font-weight: 800; color: var(--navy); }
.licence-box {
  font-family: ui-monospace, monospace; background: var(--navy); color: var(--gold-2);
  padding: 12px; border-radius: 10px; letter-spacing: 0.04em; word-break: break-all;
}
input[type="email"], input[type="text"] {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid #cfc8ba;
  font: inherit; font-size: 16px; background: #fff; -webkit-appearance: none; appearance: none;
}
.meter { height: 10px; background: #ece7dd; border-radius: 999px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--gold); }
.topic-row { display: flex; justify-content: space-between; gap: 12px; margin: 8px 0; }
.warn { color: var(--bad); }
.ok-text { color: var(--ok); font-weight: 800; }
.hidden { display: none !important; }

.creator { color: #f3e6c0; font-weight: 600; line-height: 1.5; }
.hero .creator { color: #f3e6c0; }
.card .creator { color: var(--navy); }
.disclaimer { color: var(--muted); font-size: 0.86rem; line-height: 1.55; margin-top: 14px; }
.q-block {
  background: #fff; border: 1px solid #ece7dd; border-radius: 14px;
  padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.q-num { color: var(--muted); font-size: 0.85rem; margin: 0 0 6px; }
.select-hint { color: var(--navy); font-weight: 800; white-space: nowrap; }
.result-wrong {
  background: #fff; border-left: 4px solid var(--bad); border-radius: 12px;
  padding: 14px; margin: 12px 0; box-shadow: var(--shadow);
}
.result-wrong .source { color: var(--muted); font-size: 0.86rem; margin: 0 0 6px; }
.mark-ok { color: var(--ok); font-weight: 700; }
.mark-bad { color: var(--bad); font-weight: 700; }
.encourage { font-weight: 600; }
.score-card { text-align: left; }

.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 100;
  background: var(--gold); color: var(--navy); padding: 8px 12px; border-radius: 8px;
  font-weight: 700; text-decoration: none;
}
.skip-link:focus { left: 8px; }
.topbar { padding-top: max(12px, env(safe-area-inset-top)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.site-footer { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
#app { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.option { -webkit-tap-highlight-color: transparent; }
.option .opt-en { display: block; font-weight: 600; }
.zh-sub {
  display: block; font-weight: 500; font-size: 0.92rem; color: var(--muted);
  margin-top: 4px; line-height: 1.45;
}
.q-stem .zh-sub { font-weight: 600; font-size: 0.95rem; margin-top: 6px; }
.zh-inline { color: var(--muted); font-weight: 500; font-size: 0.92em; }
.pref-row { margin-top: 16px; text-align: left; }
.pref-row.compact { margin-top: 8px; }
.pref-toggle {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  font-weight: 700; color: inherit;
}
.hero .pref-toggle { color: var(--gold-2); }
.pref-toggle input { width: 18px; height: 18px; accent-color: var(--gold); }
.pref-hint { margin: 4px 0 10px 28px; font-size: 0.82rem; color: #d7d0c4; }
.hero .pref-hint { color: #d7d0c4; }
.card .pref-hint, section .pref-hint { color: var(--muted); }
.exam-toolbar { margin-bottom: 12px; }
.exam-timer { margin: 0 0 8px; color: var(--navy); font-weight: 700; }
.exam-timer.timer-low { color: var(--bad); }
.continue-card { margin-bottom: 16px; border: 2px solid var(--gold); }
.loading { margin: 12px 0; }
.loading::after { content: "…"; }
.mnemonic { font-size: 1.02rem; }
.footer-links {
  display: flex; flex-wrap: wrap; gap: 10px 16px; margin: 0 0 10px;
}
.footer-links a { color: var(--navy); }
.legal-page { max-width: 760px; margin: 0 auto; padding: 24px 16px 48px; }
.legal-page h1 { margin-top: 0; }
.legal-page h2 { margin-top: 22px; }
.legal-page p, .legal-page li { color: #333; }
@media (max-width: 560px) {
  .q-stem { font-size: 1.05rem; }
  .option { padding: 12px 10px; }
}

.lead.small { font-size: 0.88rem; margin-bottom: 10px; }
.exam-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 560px) { .exam-grid { grid-template-columns: repeat(3, 1fr); } }
.exam-card { text-align: center; padding: 12px 6px; min-height: 64px; }
.exam-card h3 { font-size: 1rem; margin: 0 0 4px; }
.exam-card .badge { margin-left: 0; }
.exam-card.locked h3 { color: var(--lock); }

.staging-banner {
  background: #fff4cc;
  color: #5c4300;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  padding: 6px 12px;
  border-bottom: 1px solid #e6d392;
  letter-spacing: 0.01em;
}

.mode-switch { margin-top: 14px; text-align: left; }
.mode-switch-label { font-weight: 800; margin: 0 0 8px; font-size: 0.95rem; }
.hero .mode-switch-label { color: var(--gold-2); }
.exam-toolbar .mode-switch-label { color: var(--navy); margin-bottom: 6px; }
.mode-switch-pills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.22);
}
.exam-toolbar .mode-switch-pills { background: #ece7dd; }
.mode-pill {
  border: 0;
  border-radius: 11px;
  min-height: 44px;
  padding: 8px 10px;
  font: inherit;
  font-weight: 800;
  font-size: 0.95rem;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.hero .mode-pill { color: var(--gold-2); }
.exam-toolbar .mode-pill { color: var(--navy); }
.mode-pill[aria-checked="true"] {
  background: var(--gold);
  color: var(--navy);
}
.mode-switch-hint { margin: 8px 0 0; font-size: 0.82rem; line-height: 1.45; }
.hero .mode-switch-hint { color: #d7d0c4; }
.exam-toolbar .mode-switch-hint { color: var(--muted); }
.option.locked, .option:disabled { cursor: not-allowed; }
.practice-verdict { font-size: 1.2rem; font-weight: 800; margin: 0 0 8px; text-align: center; }
.feedback.ok .practice-verdict { margin: 0; color: var(--ok); }
.feedback.bad { padding-top: 16px; }
.q-block.practice-q { margin-bottom: 8px; }

.practice-extra-label { margin: 10px 0 0; font-size: 0.88rem; font-weight: 800; color: var(--ok); text-align: left; }
.practice-extra { margin: 4px 0 0; font-weight: 500; color: var(--ink); line-height: 1.5; text-align: left; }
.feedback.ok h4 { margin-top: 12px; color: var(--ok); }
.feedback.ok .mnemonic { margin: 4px 0 0; font-weight: 500; line-height: 1.5; }
textarea {
  width: 100%; min-height: 140px; padding: 12px; border-radius: 10px; border: 1px solid #cfc8ba;
  font: inherit; font-size: 16px; background: #fff; -webkit-appearance: none; appearance: none;
  resize: vertical; line-height: 1.5;
}
.char-count { margin: 6px 0 0; font-size: 0.8rem; color: var(--muted); text-align: right; }
