/* One stylesheet for the static pages and the practice app. Mobile first; light/dark from the system. */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --text: #16181d; --muted: #5b6270; --line: #dde1e7;
  --brand: #1d4ed8; --brand-ink: #ffffff; --brand-soft: #e8efff;
  --accent: #c2410c; --accent-ink: #ffffff;
  --ok: #15803d; --ok-soft: #e7f6ec; --bad: #b91c1c; --bad-soft: #fdecec;
  --radius: 12px; --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --surface: #181b21; --text: #e8eaee; --muted: #a0a7b4; --line: #2b3038;
    --brand: #6d9bff; --brand-ink: #0b1020; --brand-soft: #1b2540;
    --accent: #fb923c; --accent-ink: #1a0d02;
    --ok: #4ade80; --ok-soft: #12291b; --bad: #f87171; --bad-soft: #301617;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); line-height: 1.6; font-size: 17px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  overflow-wrap: anywhere;
}
:lang(zh-TW) { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
  "PingFang TC", "Hiragino Sans CNS", "Microsoft JhengHei", "Noto Sans CJK TC", "Source Han Sans TC", sans-serif; }
a { color: var(--brand); }
img { max-width: 100%; }
h1 { font-size: 1.55rem; line-height: 1.3; margin: .6em 0 .4em; }
h1 small { display: block; font-size: .9rem; color: var(--muted); font-weight: normal; margin-top: .2em; }
h2 { font-size: 1.2rem; line-height: 1.35; margin: 1.2em 0 .5em; }
h3 { font-size: 1.05rem; margin: 1em 0 .4em; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.muted, .meta { color: var(--muted); }
.meta { font-size: .88rem; }
.lead { color: var(--muted); }

/* header / footer */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-in { display: flex; align-items: center; gap: 10px; min-height: 52px; flex-wrap: wrap; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); margin-right: auto; white-space: nowrap; }
.langs { display: flex; gap: 2px; }
.langs a, .langs span, .seg button {
  min-height: 36px; min-width: 44px; padding: 4px 8px; border-radius: 8px; display: inline-flex; align-items: center;
  justify-content: center; font-size: .9rem; text-decoration: none; color: var(--muted); border: 0; background: none; font: inherit;
}
.langs span[aria-current], .seg button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.foot { color: var(--muted); font-size: .82rem; margin-top: 40px; padding: 16px 0 32px; border-top: 1px solid var(--line); }

/* building blocks */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: var(--shadow); }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.cards { display: grid; gap: 12px; margin: 12px 0; }
.cards .card { margin: 0; }
.exam-card { display: block; text-decoration: none; color: var(--text); }
.exam-card h3 { margin: 0 0 .3em; color: var(--brand); }
.exam-card p { margin: .2em 0; }
.points { padding-left: 1.2em; color: var(--muted); }
.crumb { font-size: .9rem; margin: 12px 0 0; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 10px 18px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; text-align: center; max-width: 100%;
}
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.block { display: flex; width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.unlock-card p { margin-top: 0; }
.topic-list { list-style: none; padding: 0; margin: 0; }
.topic-list li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: space-between; }

/* questions on the public pages */
.q-img { margin: 0 0 8px; text-align: center; }
.q-img img { width: 160px; height: 160px; }
.q-img.wide img { width: 100%; max-width: 400px; height: auto; }
.q-stem { font-size: 1.08rem; margin: 0 0 4px; }
.en { color: var(--muted); font-size: .9rem; display: block; }
.opts { padding-left: 1.6em; }
.opts li { margin: 4px 0; }
.opts li.ok { color: var(--ok); font-weight: 600; }
.src { font-size: .85rem; color: var(--muted); }
.cta-end { text-align: center; }

/* practice app */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; width: 100%; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; padding: 2px; }
.switch { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; font-size: .9rem; color: var(--muted); cursor: pointer; }
.switch input { width: 20px; height: 20px; margin: 0; }
.status { display: flex; flex-direction: column; gap: 10px; }
.status p { margin: 0; }
.status.ok { border-color: var(--ok); }
.row-btn {
  display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px; min-height: 52px;
  padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--text);
  font: inherit; text-align: left; cursor: pointer;
}
.row-btn:last-child { border-bottom: 0; }
.row-btn .meta { text-align: right; flex-shrink: 0; max-width: 45%; }
.list { padding: 0 4px; }
.qhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 12px 0 4px; color: var(--muted); font-size: .9rem; }
.qcard .q-img img { cursor: zoom-in; }
.choices { display: grid; gap: 10px; margin: 14px 0 6px; }
.choice {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; min-height: 52px; padding: 12px; text-align: left;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
}
.choice .k { flex: 0 0 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--line); display: inline-flex; align-items: center; justify-content: center; font-size: .85rem; font-weight: 600; }
.choice .ct { flex: 1; min-width: 0; }
.choice.sel { border-color: var(--brand); background: var(--brand-soft); }
.choice.right { border-color: var(--ok); background: var(--ok-soft); }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); }
.choice[disabled] { cursor: default; color: var(--text); }
.feedback { border-radius: 10px; padding: 12px; margin: 10px 0; }
.feedback.right { background: var(--ok-soft); }
.feedback.wrong { background: var(--bad-soft); }
.feedback h3 { margin: 0 0 4px; font-size: 1rem; }
.feedback.right h3 { color: var(--ok); }
.feedback.wrong h3 { color: var(--bad); }
.feedback p { margin: 4px 0; }
.nav { display: flex; gap: 10px; margin: 14px 0; }
.nav .btn { flex: 1; }
.tag { display: inline-block; font-size: .78rem; padding: 1px 8px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); }
.timer { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; margin: 12px 0; }
.palette button { min-height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: .85rem; }
.palette button.done { background: var(--brand-soft); border-color: var(--brand); }
.palette button.cur { outline: 2px solid var(--brand); }
.verdict { font-size: 1.6rem; font-weight: 700; margin: 0; }
.verdict.pass { color: var(--ok); }
.verdict.fail { color: var(--bad); }
.score { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.score:last-child { border-bottom: 0; }
.score .ok { color: var(--ok); font-weight: 600; } .score .no { color: var(--bad); font-weight: 600; }
#overlay { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .6); display: flex; align-items: center; justify-content: center; padding: 16px; }
#overlay[hidden] { display: none; }
.dialog { background: var(--surface); color: var(--text); border-radius: var(--radius); padding: 20px; max-width: 440px; width: 100%; max-height: 90vh; overflow: auto; }
.zoom { background: #fff; border-radius: var(--radius); padding: 12px; max-width: 100%; width: 560px; }
.zoom img { width: 100%; height: auto; display: block; }

@media (min-width: 640px) {
  h1 { font-size: 1.9rem; }
  .cards { grid-template-columns: 1fr 1fr; }
}
