:root {
  color-scheme: light dark;
  --canvas: #f6f6f3;
  --surface: #fff;
  --text: #1c1c1e;
  --muted: #5f5f61;
  --line: #deded7;
  --link: #755a00;
  --yellow: #ffd400;
  --yellow-hover: #f0c800;
  --highlight: #ffed9b;
  --ok: #17683f;
  --ok-bg: #e8f5ec;
  --bad: #a73328;
  --bad-bg: #fbedeb;
  --law: #fffaf0;
  --hero: #fff7d9;
  --hero-side: #f9e8a0;
  --charcoal: #222321;
  --radius: 16px;
  --gutter: 32px;
  --wrap: 1232px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #171816;
    --surface: #222320;
    --text: #f5f4f0;
    --muted: #bcbcb1;
    --line: #40403a;
    --link: #f6d763;
    --highlight: #685608;
    --ok: #8fe0af;
    --ok-bg: #153523;
    --bad: #ff9b92;
    --bad-bg: #3d2321;
    --law: #2b281c;
    --hero: #262318;
    --hero-side: #3d3212;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font: 16px/1.72 -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", "Noto Sans CJK TC", sans-serif;
}
img { display: block; max-width: 100%; height: auto; }
a { color: var(--link); text-underline-offset: .2em; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 3px; }
[hidden] { display: none !important; }
[id] { scroll-margin-top: 24px; }
p { margin: .55rem 0; }
h1, h2, h3 { line-height: 1.3; margin: 0; overflow-wrap: anywhere; }
h2 { font-size: clamp(1.4rem, 1.14rem + 1vw, 1.95rem); }
h3 { font-size: 1.05rem; }
.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
.meta { font-size: .875rem; color: var(--muted); }
.lead { font-size: 1.075rem; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 22px 0 0; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .7rem 1.2rem;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--yellow);
  color: #1c1c1e;
  font-weight: 700;
  line-height: 1.4;
  text-decoration: none;
}
.btn:hover { background: var(--yellow-hover); }
.btn.alt { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn.alt:hover { border-color: var(--text); }

/* Shared navigation and footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 22px; min-height: 72px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); white-space: nowrap; font-weight: 750; text-decoration: none; }
.brand img { width: 38px; height: 38px; border-radius: 9px; }
.site-nav { display: flex; align-items: center; gap: 26px; font-size: .925rem; }
.site-nav .nav-link { color: var(--muted); text-decoration: none; white-space: nowrap; }
.site-nav .nav-link:hover, .site-nav .nav-link[aria-current] { color: var(--text); text-decoration: underline; text-decoration-color: var(--yellow); text-decoration-thickness: 3px; text-underline-offset: 7px; }
.header-download { padding: .48rem .9rem; font-size: .875rem; white-space: nowrap; }
.site-footer { background: var(--surface); border-top: 1px solid var(--line); padding-block: 32px 44px; }
.footer-inner { display: grid; grid-template-columns: minmax(0, 1fr) minmax(210px, 280px); gap: 48px; font-size: .875rem; color: var(--muted); }
.footer-inner p { max-width: 68ch; }
.footer-inner nav { display: flex; flex-wrap: wrap; align-content: start; gap: 6px 16px; }
.footer-inner nav a { color: inherit; }
.footer-brand { color: var(--text); font-weight: 700; text-decoration: none; }

/* Product homepage */
.home-hero { position: relative; overflow: hidden; background: var(--hero); }
.hero-inner { display: grid; grid-template-columns: minmax(0, 1.13fr) minmax(0, 1fr); align-items: center; gap: 34px; min-height: 490px; }
.hero-copy { position: relative; z-index: 1; padding-block: 50px; }
.hero-copy h1 { font-size: clamp(2.25rem, 1.25rem + 3vw, 4.2rem); line-height: 1.13; font-weight: 800; letter-spacing: -.045em; }
.hero-copy h1 span { display: block; margin-top: .12em; font-size: .77em; letter-spacing: -.025em; }
.hero-copy .lead { margin: 20px 0 0; max-width: 32em; color: var(--muted); }
.hero-copy .actions { margin-top: 26px; }
.hero-visual { position: relative; align-self: stretch; min-height: 360px; isolation: isolate; }
.hero-visual::before {
  content: "";
  position: absolute;
  inset: 10% -2% -18% 4%;
  z-index: -1;
  border-radius: 48% 48% 0 0;
  background-color: var(--hero-side);
  background-image: linear-gradient(90deg, rgb(118 91 0 / 8%) 1px, transparent 1px), linear-gradient(rgb(118 91 0 / 8%) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(#000 60%, transparent 98%);
}
.phone {
  position: absolute;
  width: clamp(158px, 51%, 262px);
  overflow: hidden;
  border: 7px solid #232421;
  border-radius: 32px;
  background: #fff;
  box-shadow: 0 22px 46px rgb(55 43 5 / 22%);
}
.phone img { width: 100%; }
.phone-front { top: 8%; left: 10%; transform: rotate(-7deg); }
.phone-back { top: 18%; right: 4%; transform: rotate(8deg); }
.stat-strip { background: var(--surface); border-bottom: 1px solid var(--line); }
.stat-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-block: 0; padding-block: 19px; }
.stat { display: flex; justify-content: center; align-items: baseline; flex-wrap: wrap; gap: 2px 10px; padding: 3px 12px; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat dt { color: var(--muted); font-size: .92rem; }
.stat dd { order: -1; margin: 0; font-size: 1.75rem; line-height: 1.3; font-weight: 750; font-variant-numeric: tabular-nums; }
.home-section { padding-block: 58px; }
.home-section h2 + p { color: var(--muted); }
.home-section .grid { margin: 22px 0 0; }
.entry-grid .card { position: relative; display: flex; flex-direction: column; align-items: start; gap: 6px; padding: 24px; }
.entry-grid .card::before { content: ""; width: 26px; height: 4px; background: var(--yellow); border-radius: 3px; margin-bottom: 8px; }
.entry-grid .card::after { content: ""; position: absolute; top: 27px; right: 25px; width: 7px; height: 7px; border: solid var(--link); border-width: 1.5px 1.5px 0 0; transform: rotate(45deg); }
.entry-grid h3 { padding-right: 15px; font-size: 1.2rem; }
.features { background: var(--surface); border-block: 1px solid var(--line); }
.feature-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 40px; margin-top: 25px; }
.feature { border-top: 1px solid var(--line); padding-top: 14px; }
.feature p { color: var(--muted); margin-bottom: 0; }
.home-details { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 36px; }
.home-details .box { margin: 14px 0 0; }
.exam-dates { margin: 10px 0 14px; padding-left: 1.3rem; }

/* Resource pages */
.page-head { background: var(--charcoal); color: #fff; border-bottom: 3px solid var(--yellow); }
.page-head .wrap { padding-block: 34px 40px; }
.page-head h1 { font-size: clamp(1.9rem, 1.25rem + 1.9vw, 3.05rem); }
.page-head .lead { max-width: 55em; color: #e3e2db; margin: 12px 0 0; }
.crumbs { display: flex; align-items: baseline; flex-wrap: wrap; gap: .45rem; margin: 0 0 10px; font-size: .875rem; color: #e3e2db; }
.crumbs a { color: #f5dd83; }
.page-head :focus-visible { outline-color: var(--yellow); }
.main-content { padding-block: 24px 58px; }
.reading-layout { display: grid; grid-template-columns: minmax(0, 1fr) 284px; gap: 34px; align-items: start; }
.reading-main { grid-area: 1 / 1; min-width: 0; }
.reading-side { grid-area: 1 / 2; position: sticky; top: 20px; }
.main-content h2 { margin-block: 38px 12px; }
.main-content h2:first-child { margin-top: 0; }
.main-content h3 { margin-block: 22px 8px; }
.box, .card, .q, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.box { padding: 16px 20px; margin: 0 0 16px; }
.box > :first-child { margin-top: 0; }
.box > :last-child { margin-bottom: 0; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-block: 14px; }
.card { display: block; padding: 16px 18px; color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--link); }
.card h3 { margin: 0 0 4px; }
.card p { margin: 0; color: var(--muted); font-size: .94rem; }
.panel { padding: 17px; margin-bottom: 14px; }
.panel-name { margin: 0 0 7px; font-weight: 750; }
.quiz-panel { max-height: calc(100vh - 72px); overflow-y: auto; }
.reading-main .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.side-links { display: grid; gap: 2px; }
.side-links a { padding: 5px 0; }
.pager { display: flex; justify-content: space-between; gap: 10px 20px; flex-wrap: wrap; margin: 26px 0 0; }
.cta { margin-top: 35px; }
.cta h2 { margin: 0; font-size: 1.2rem; }
.cta .actions { margin-top: 14px; }
.app { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.app img { width: 48px; height: 48px; border-radius: 11px; flex: 0 0 48px; }
.app .meta { margin: 0; }

/* Question cards, answer feedback and references */
.q { padding: 19px 22px; margin-block: 13px; }
.q:target { border-color: var(--link); }
.tag { display: inline-block; font-size: .8rem; color: var(--muted); background: var(--canvas); border: 1px solid var(--line); border-radius: 6px; padding: 1px 8px; margin: 0 6px 3px 0; }
.q-tags { margin: 0; }
.qno { font-size: .9rem; font-weight: 650; color: var(--muted); margin-top: 0; }
.stem { margin: .55rem 0 .8rem; font-size: 1.075rem; font-weight: 650; }
.opts { list-style: none; display: grid; gap: 7px; padding: 0; margin: .6rem 0; }
.opt { display: flex; gap: 10px; width: 100%; text-align: left; font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: .48rem .75rem; cursor: pointer; }
.opt b { flex: 0 0 1.3rem; }
.opt:not([aria-disabled]):hover, .opt[aria-pressed="true"] { border-color: var(--link); background: var(--law); }
.done .opt { cursor: default; }
.done .opt.right { border-color: var(--ok); background: var(--ok-bg); }
.done .opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.right::after, .opt.wrong::after { margin-left: auto; font-weight: 750; }
.opt.right::after { content: "✓" / ""; color: var(--ok); }
.opt.wrong::after { content: "✕" / ""; color: var(--bad); }
.check { font: inherit; font-weight: 700; border: 0; border-radius: 9px; padding: .45rem 1.1rem; background: var(--yellow); color: #1c1c1e; cursor: pointer; }
.check:disabled { opacity: .5; cursor: default; }
.fb { font-weight: 650; margin: .3rem 0; }
.fb:empty { margin: 0; }
.fb.ok { color: var(--ok); }
.fb.no { color: var(--bad); }
details { margin-top: .45rem; }
summary { cursor: pointer; color: var(--link); }
.src { background: var(--law); border: 1px solid var(--line); border-inline-start: 3px solid var(--link); border-radius: 5px 10px 10px 5px; padding: .65rem .95rem; margin: .6rem 0; }
.src p { margin: .16rem 0; }
.src blockquote { margin: .45rem 0; font: 1.02rem/1.85 "Songti TC", "Noto Serif TC", "PMingLiU", serif; white-space: pre-line; }
mark { background: var(--highlight); color: inherit; box-decoration-break: clone; }
.score { margin: 0; font-size: .92rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.mobile-score { display: none; }
.question-links { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); list-style: none; gap: 4px; margin: 12px 0 0; padding: 0; }
.question-links a { display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; color: var(--text); padding-block: 3px; font-size: .8rem; font-variant-numeric: tabular-nums; text-decoration: none; }
.question-links a:hover { border-color: var(--link); }
.question-links .ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok); }
.question-links .no { color: var(--bad); background: var(--bad-bg); border-color: var(--bad); }

/* Tables, formula and version comparison */
.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .94rem; }
th, td { border-bottom: 1px solid var(--line); padding: .5rem .65rem; text-align: left; vertical-align: top; }
th { font-weight: 700; background: var(--law); }
tr:last-child td { border-bottom: 0; }
.n { text-align: right; font-variant-numeric: tabular-nums; }
td.n { white-space: nowrap; }
.steps { padding-left: 1.4rem; }
.steps li { margin: .65rem 0; }
.formula { display: inline-block; border-radius: 7px; background: var(--canvas); padding: .15rem .45rem; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.work { white-space: pre-line; }
.calcq h3 { margin: 0 0 7px; }
.calcq label { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: .5rem 0; }
.calcq input { width: 9rem; max-width: 100%; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: inherit; font: inherit; }
.calcq input.right { border-color: var(--ok); background: var(--ok-bg); }
.calcq input.wrong { border-color: var(--bad); background: var(--bad-bg); }
del { color: var(--bad); background: var(--bad-bg); }
ins { color: var(--ok); background: var(--ok-bg); text-underline-offset: 3px; }
.diff p { margin: .2rem 0; }

@media (max-width: 960px) {
  :root { --gutter: 24px; }
  .reading-layout { grid-template-columns: minmax(0, 1fr) 228px; gap: 20px; }
  .hero-inner { min-height: 425px; gap: 16px; }
  .hero-copy h1 { font-size: clamp(2.15rem, 1.1rem + 3vw, 3.4rem); }
  .phone-front { left: 4%; }
  .phone-back { right: 0; }
}

@media (max-width: 760px) {
  .reading-layout { display: block; }
  .reading-side:has(.quiz-panel) { display: none; }
  .side-links { display: flex; flex-wrap: wrap; gap: 4px 16px; }
  .mobile-score:not([hidden]) { display: block; position: sticky; z-index: 2; top: 0; padding: 9px 0; background: var(--canvas); border-bottom: 1px solid var(--line); }
  .q[id] { scroll-margin-top: 58px; }
  .hero-inner { grid-template-columns: 1fr; gap: 0; }
  .hero-copy { padding-block: 36px 8px; }
  .hero-visual { width: min(100%, 470px); justify-self: center; min-height: 310px; }
  .phone-front { left: 12%; }
  .phone-back { right: 6%; }
  .grid:not(.entry-grid) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-details { gap: 20px; }
  .stat { flex-direction: column; align-items: center; gap: 3px; }
}

@media (max-width: 540px) {
  :root { --gutter: 18px; }
  .header-inner { display: grid; grid-template-columns: 1fr auto; min-height: auto; gap: 0 8px; }
  .brand { min-height: 58px; font-size: .96rem; }
  .brand img { width: 32px; height: 32px; border-radius: 8px; }
  .header-download { justify-self: end; }
  .site-nav { grid-row: 2; grid-column: 1 / -1; gap: 20px; padding-block: 0 11px; font-size: .86rem; }
  .hero-visual { min-height: 275px; }
  .phone { border-width: 5px; border-radius: 24px; }
  .phone-front { left: 7%; }
  .phone-back { right: 4%; }
  .stat-list { padding-block: 13px; }
  .stat { padding-inline: 3px; }
  .stat dd { font-size: 1.35rem; }
  .stat dt { font-size: .72rem; text-align: center; }
  .home-section { padding-block: 36px; }
  .home-details, .feature-grid, .grid, .grid:not(.entry-grid), .reading-main .grid, .footer-inner { grid-template-columns: 1fr; gap: 12px; }
  .entry-grid .card { padding: 15px 17px; }
  .entry-grid .card::before { display: none; }
  .page-head .wrap { padding-block: 24px 27px; }
  .main-content { padding-block: 16px 36px; }
  .box, .q { padding: 13px 14px; }
  th, td { padding-inline: .38rem; }
}
