:root {
  color-scheme: light;
  --paper: #f2f1e8;
  --panel: #fffef9;
  --ink: #1d3029;
  --muted: #526259;
  --green: #1c5345;
  --forest: #153f35;
  --line: #dbdfd4;
  --sage: #e8f1e7;
  --rust: #923c2e;
  --rust-wash: #fbf0eb;
  --gold: #dec88c;
  font: 16px/1.65 "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; min-height: 100vh; display: flex; flex-direction: column; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2rem, 6vw, 3.25rem); line-height: 1.18; letter-spacing: -.045em; overflow-wrap: anywhere; }
h2 { font-size: clamp(1.22rem, 4vw, 1.46rem); line-height: 1.4; }
h3 { font-size: 1rem; line-height: 1.5; }
button, select, input, textarea { font: inherit; }
a { color: var(--green); text-underline-offset: .22em; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid #94621d;
  outline-offset: 3px;
}
[tabindex="-1"]:focus { outline: none; }

.site-header { color: #fffdf5; background: var(--forest); border-bottom: 2px solid var(--gold); }
.site-header-inner {
  max-width: 58rem;
  padding: 12px clamp(16px, 4vw, 30px);
  min-height: 64px;
  margin: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.site-header a { color: inherit; text-decoration: none; }
.brand { align-items: center; display: inline-flex; gap: 9px; font-weight: 750; letter-spacing: .07em; font-size: 1.06rem; }
.brand-mark {
  width: 20px; height: 21px; display: grid; align-content: center; gap: 2px;
  padding: 3px 4px; border: 1px solid #acbfa5; border-radius: 2px 4px 4px 2px;
}
.brand-mark span { display: block; background: var(--gold); height: 1px; }
.brand-mark span:last-child { width: 70%; }
.product { font-size: .87rem; letter-spacing: .06em; color: #e2ebdf; }

.layout { width: min(100% - 28px, 54rem); margin: clamp(17px, 5vw, 44px) auto 0; flex: 1; }
.narrow { max-width: 43rem; margin-inline: auto; }
.breadcrumbs { font-size: .85rem; min-height: 28px; margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 6px; color: var(--muted); }
.breadcrumbs a { color: var(--muted); }
.hero {
  margin-bottom: 16px;
  position: relative;
  border-radius: 17px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: clamp(23px, 6vw, 47px);
  display: grid;
  gap: 9px;
  box-shadow: 0 11px 27px #1d362310;
}
.hero .lead { margin-top: 2px; max-width: 40ch; }
.eyebrow { color: var(--green); font-size: .83rem; letter-spacing: .075em; font-weight: 750; }
.lead, .muted, .hint, .footnote { color: var(--muted); }
.muted, .hint, .footnote { font-size: .87rem; }
.load-state, .empty { padding: 25px 16px; color: var(--muted); text-align: center; }
.site-footer { padding: 22px 15px 26px; text-align: center; display: flex; justify-content: center; flex-wrap: wrap; column-gap: 12px; row-gap: 2px; color: var(--muted); font-size: .8rem; }
.sheet {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: clamp(16px, 4vw, 25px);
  background: var(--panel);
}
.sheet + .sheet, .group + .group { margin-top: 13px; }
.sheet > h2, .sheet > header { margin-bottom: 11px; }
.group { display: grid; gap: 8px; }
.group-title { font-size: .86rem; color: var(--muted); padding: 3px 1px; font-weight: 700; }
.entry-grid { display: grid; gap: 11px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); }
.entry {
  color: var(--ink); text-decoration: none; min-height: 92px; display: grid; align-content: start;
  gap: 4px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel);
}
.entry:hover { border-color: var(--green); background: #fcfef8; }
.entry strong { color: var(--green); font-size: 1.08rem; }
.entry > small { color: var(--muted); font-size: .82rem; }
.entry-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.entry-icon { color: var(--green); font-size: 1.1rem; font-weight: 600; }
.item-list { display: grid; gap: 7px; }
.list-link { font-size: .95rem; min-height: 45px; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 10px; text-decoration: none; border-radius: 7px; }
.list-link:hover { background: var(--sage); }
.list-link + .list-link { border-top: 1px solid #e9ebe0; }
.list-link span:last-child { text-align: end; flex-shrink: 0; max-width: 48%; }

.button, .text-button { font-weight: 700; cursor: pointer; text-decoration: none; text-align: center; }
.button {
  min-height: 46px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  line-height: 1.4;
}
.primary { background: var(--green); color: white; }
.primary:hover:not(:disabled) { background: var(--forest); }
.primary:disabled { background: #e5eae4; color: #55635a; cursor: default; }
.secondary { background: var(--panel); color: var(--green); border-color: var(--line); }
.secondary:hover { background: var(--sage); }
.text-button { min-height: 44px; border: 0; background: transparent; padding: 7px 3px; color: var(--green); text-decoration: underline; text-underline-offset: .22em; }
.actions, .paper-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.actions > .button { min-width: min(100%, 9rem); }
.block { width: 100%; }
.stack { display: grid; gap: 11px; }
.row { display: flex; gap: 9px; flex-wrap: wrap; justify-content: space-between; align-items: center; }
.row > .eyebrow { min-width: 0; }
.notice { border-left: 3px solid #8fa792; padding: 10px 12px; margin-bottom: 13px; background: var(--sage); color: var(--forest); }

.quiz { position: relative; }
.quiz .quiz-head { display: grid; gap: 5px; margin-bottom: 14px; }
.quiz .quiz-head h1 { font-size: clamp(1.28rem, 4.2vw, 1.7rem); line-height: 1.38; letter-spacing: -.015em; }
.progress-text { color: var(--muted); font-size: .86rem; font-variant-numeric: tabular-nums; }
progress { width: 100%; height: 8px; display: block; accent-color: var(--green); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { width: 100%; font-size: clamp(1.04rem, 4vw, 1.18rem); line-height: 1.6; font-weight: 750; padding: 0; margin-bottom: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.choices { display: grid; gap: 8px; }
.choice {
  display: grid; grid-template-columns: 18px 1.2rem minmax(0, 1fr);
  column-gap: 8px; align-items: start; min-height: 48px;
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
.choice input { margin: .31em 0 0; accent-color: var(--green); width: 16px; height: 16px; }
.choice .letter { color: var(--green); font-weight: 750; }
.choice:has(:checked), .choice.correct { background: var(--sage); border-color: var(--green); }
.choice.incorrect { background: var(--rust-wash); border-color: var(--rust); }
.choice:has(:disabled) { cursor: default; }
.choice-text { overflow-wrap: anywhere; white-space: pre-wrap; }
.answer-feedback { background: var(--sage); color: var(--forest); border-radius: 8px; margin-top: 13px; padding: 10px 12px; }
.answer-feedback.incorrect { background: var(--rust-wash); color: var(--rust); }
.number-nav { margin-top: 13px; }
.number-nav summary { min-height: 44px; cursor: pointer; font-weight: 750; color: var(--green); padding: 8px 3px; }
.number-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(37px, 1fr)); gap: 5px; }
.number-grid button { min-height: 39px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); padding: 2px; cursor: pointer; font-variant-numeric: tabular-nums; }
.number-grid button.answered { background: var(--sage); }
.number-grid button[aria-current="step"] { background: var(--green); border-color: var(--green); color: #fff; }
.paper-actions { justify-content: space-between; }
.paper-actions .submit-paper { margin-inline-start: auto; }

.score-box { display: grid; gap: 6px; }
.score-number { color: var(--forest); font-weight: 750; font-size: clamp(2rem, 8vw, 3.15rem); line-height: 1.18; font-variant-numeric: tabular-nums; }
.score-label { color: var(--muted); font-size: .9rem; }
.result-list { display: grid; gap: 6px; }
.question-result { border: 1px solid var(--line); border-radius: 7px; padding: 0 10px; }
.question-result summary { min-height: 44px; cursor: pointer; display: list-item; padding: 8px 1px; font-weight: 700; overflow-wrap: anywhere; }
.question-result summary span { margin-inline-end: 8px; }
.item-body { display: grid; gap: 7px; padding: 4px 1px 11px; }
.item-body .stem { white-space: pre-wrap; overflow-wrap: anywhere; }
.item-body ol { margin: 0; padding-inline-start: 24px; }
.item-body li { padding: 2px 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.item-body li.key-answer { font-weight: 750; color: var(--green); }
.flag { color: var(--rust); font-size: .82rem; }
.group-stem { background: var(--sage); padding: 9px 11px; border-radius: 7px; margin-bottom: 11px; white-space: pre-wrap; }
.book { background: var(--sage); margin-top: 13px; }
.book a { display: inline-flex; min-height: 43px; align-items: center; font-weight: 750; }

dialog { width: min(100% - 24px, 29rem); max-height: 84vh; overflow: auto; color: var(--ink); background: var(--panel); border-radius: 12px; border: 1px solid var(--line); padding: 20px; }
dialog::backdrop { background: #122c24a3; }
dialog form { display: grid; gap: 11px; }
dialog input, dialog select, dialog textarea { width: 100%; border: 1px solid #95a497; padding: 7px 9px; border-radius: 6px; background: white; color: var(--ink); }
dialog label { display: grid; gap: 4px; font-weight: 700; }
dialog textarea { resize: vertical; min-height: 90px; }
dialog .actions { justify-content: flex-end; }

@media (max-width: 480px) {
  .paper-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .paper-actions .submit-paper { margin-inline-start: 0; grid-column: 1 / -1; }
  .actions > .button { flex: 1 1 min(100%, 9rem); }
}
