:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17312b;
  background: #f5f6ef;
}

* { box-sizing: border-box; }
body, main, form, label, .practice-card > * { min-width: 0; }
main { overflow-wrap: anywhere; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
.site-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1.5rem 7%; border-bottom: 1px solid #dce4d9; font-size: .9rem; }
.brand { color: inherit; font-size: 1.1rem; font-weight: 700; text-decoration: none; }
main { width: min(100% - 3rem, 900px); margin: auto; padding: 5rem 0; }
.eyebrow { color: #49725e; font-size: .75rem; font-weight: 700; letter-spacing: .12em; }
h1 { font-size: clamp(2.25rem, 6vw, 4.5rem); line-height: 1.2; letter-spacing: -.04em; margin: 1.5rem 0; }
.intro { color: #4d655a; font-size: 1.1rem; line-height: 1.8; }
.notice { max-width: 38rem; margin-top: 3.5rem; padding: 1.5rem; border: 1px solid #d5e2d2; border-radius: .75rem; background: #fff; }
.notice h2 { margin: 0 0 .5rem; font-size: 1rem; }
.notice p { margin: 0; color: #4d655a; line-height: 1.7; }
footer { padding: 1.5rem 7%; color: #536b5d; font-size: .8rem; }
nav { display: flex; flex-wrap: wrap; gap: 1.25rem; }
.site-header nav a { display: inline-flex; align-items: center; min-height: 2.5rem; }
a { color: #275d45; }
.account-main { max-width: 600px; }
.account-main h1 { font-size: clamp(2rem, 5vw, 3rem); }
.form-card { margin-top: 2rem; }
form { display: grid; gap: .75rem; }
label { font-weight: 600; }
input:not([type="hidden"]):not([type="checkbox"]), textarea, select { width: 100%; padding: .8rem; font: inherit; border: 1px solid #9bb4a1; border-radius: .4rem; }
textarea { resize: vertical; }
label { display: grid; gap: .4rem; }
label:has(input[type="checkbox"]) { display: flex; align-items: baseline; }
button { width: fit-content; max-width: 100%; padding: .8rem 1.4rem; border: 0; border-radius: .4rem; background: #275d45; color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid #bd7b16; outline-offset: 3px; }
.error { color: #a32922; }
.inline-form { display: inline; margin-left: .5rem; }
.inline-form button { padding: .2rem .5rem; background: #f0f4ee; color: #275d45; font-size: .8rem; }
li { margin: .5rem 0; line-height: 1.6; }
.practice-list { list-style: none; padding: 0; display: grid; gap: .75rem; }
.practice-card { margin: 0; padding: 1.25rem; border: 1px solid #d5e2d2; border-radius: .75rem; background: #fff; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.practice-card p { color: #4d655a; margin: .35rem 0 0; }
.practice-link { font-weight: 600; }
.preview-note { padding: .75rem 1rem; border-left: 3px solid #bd7b16; background: #fff8e7; }
/* ---- practice workspace + question palette (答题卡) ---- */
.account-main.wide { max-width: 1180px; width: min(100% - 3rem, 1180px); padding-block: 2.5rem; }
.practice-shell { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 2rem; align-items: start; }
.practice-workspace { min-width: 0; display: flex; flex-direction: column; gap: 1rem; }
.back-link { margin: 0; font-size: .9rem; }
.practice-head h1 { font-size: clamp(1.6rem, 3vw, 2.1rem); line-height: 1.3; letter-spacing: -.02em; margin: .2rem 0 .4rem; }
.practice-meta { margin: 0; color: #4d655a; font-size: .9rem; }
.practice-workspace .practice-material,
.practice-workspace .practice-question,
.practice-workspace .score-card,
.practice-workspace .preview-note { margin: 0; }
.practice-material .passage { font-family: Georgia, "Songti SC", "Source Han Serif SC", serif; font-size: 1.04rem; line-height: 1.9; }

.palette { position: sticky; top: 1.5rem; max-height: calc(100vh - 3rem); overflow: auto; padding: 1.1rem 1.15rem; background: #fff; border: 1px solid #d5e2d2; border-radius: .75rem; font-size: .9rem; }
.palette-head h2 { margin: 0; font-size: .95rem; }
.palette-count { margin: .35rem 0 .55rem; color: #4d655a; font-size: .85rem; }
.palette-count strong { color: #17312b; font-size: 1.15rem; }
.palette-progress { height: .35rem; margin-bottom: .9rem; border-radius: 999px; background: #e7ece4; overflow: hidden; }
.palette-progress > span { display: block; height: 100%; border-radius: inherit; background: #275d45; }
.palette-body { display: block; }
.palette-group h3 { display: block; margin: .9rem 0 .45rem; font-size: .72rem; line-height: 1.5; letter-spacing: .06em; color: #49725e; }
.palette-range { margin-left: .35rem; color: #94a89b; font-variant-numeric: tabular-nums; white-space: nowrap; }
.palette-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.05rem, 1fr)); gap: .35rem; }
.palette-item { position: relative; display: grid; place-items: center; min-height: 2.05rem; border: 1px solid #c7d6c7; border-radius: .45rem; background: #fff; color: inherit; font-size: .85rem; text-decoration: none; font-variant-numeric: tabular-nums; }
.palette-item:hover { border-color: #275d45; }
.palette-item:focus-visible { outline: 3px solid #bd7b16; outline-offset: 2px; }
.palette-num { line-height: 1; }
.palette-mark { position: absolute; right: .2rem; bottom: .08rem; font-size: .5rem; line-height: 1; opacity: .9; }
.palette-item.is-answered { background: #e8f1e9; border-color: #9bb4a1; }
.palette-item.is-current { background: #275d45; border-color: #275d45; color: #fff; font-weight: 700; }
.palette-foot { margin-top: 1rem; }
.palette-note { margin: 0 0 .5rem; font-size: .78rem; color: #7b9486; }
.palette-jump { display: inline-block; font-size: .82rem; font-weight: 600; }
.palette-done { margin: 0; font-size: .82rem; color: #49725e; }
.palette-legend { display: flex; flex-wrap: wrap; gap: .35rem .8rem; margin: .9rem 0 0; padding: .8rem 0 0; border-top: 1px solid #e7ece4; list-style: none; font-size: .75rem; color: #4d655a; }
.palette-legend li { display: flex; align-items: center; gap: .3rem; margin: 0; }
.swatch { flex: none; width: .7rem; height: .7rem; border: 1px solid #c7d6c7; border-radius: .2rem; background: #fff; }
.swatch.is-current { background: #275d45; border-color: #275d45; }
.swatch.is-answered { background: #e8f1e9; border-color: #9bb4a1; }
/* result states */
.palette-item.is-correct, .swatch.is-correct { background: #e8f1e9; border-color: #9bb4a1; }
.palette-item.is-incorrect, .swatch.is-incorrect { background: #fbeaea; border-color: #d9a3a3; }
.palette-item.is-incorrect { color: #a32922; }
.palette-item.is-unanswered, .swatch.is-unanswered { border-style: dashed; }
.palette-item.is-unanswered { color: #7b9486; }
.palette-item.is-unscored, .swatch.is-unscored { background: #fff8e7; border-color: #e3c98a; }
.palette-item.is-subjective, .swatch.is-subjective { background: #eef1f6; border-color: #aab8d4; }
.palette-item.is-viewing { box-shadow: inset 0 0 0 2px #17312b; font-weight: 700; }
.practice-material, .practice-question { background: white; border: 1px solid #d5e2d2; border-radius: .75rem; padding: 1.25rem; margin: 1rem 0; }
.practice-material h2, .practice-question h2 { font-size: 1.2rem; }
.passage { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.75; margin-bottom: 1rem; }
.practice-image { display: block; max-width: 100%; height: auto; }
.practice-question figure, .practice-material figure { margin: 1rem 0; }
figcaption { margin-top: .5rem; font-size: .9rem; }
.choice { display: flex; align-items: baseline; gap: .7rem; padding: .5rem; font-weight: 400; }
.choice input[type="radio"] { width: auto; flex: none; }
.answer-choices { min-width: 0; border: 0; padding: 0; margin: 0; }
.answer-choices legend { font-weight: 600; margin-bottom: .5rem; }
.practice-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.score-card { padding: 1.25rem; border: 1px solid #c7d6c7; border-radius: .75rem; background: #fff; }
.score-card h2 { font-size: 1.25rem; line-height: 1.5; margin-top: 0; }
.score-card p { line-height: 1.7; }
.result-status { font-weight: 700; padding-block: .75rem; border-block: 1px solid #dce4d9; }
.result-options { padding-left: 1.75rem; overflow-wrap: anywhere; }
@media (max-width: 940px) {
  .practice-shell { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
  .palette { position: static; order: 2; max-height: none; }
}
@media (max-width: 520px) {
  .practice-card { align-items: flex-start; flex-direction: column; }
  .site-header { padding: 1rem; flex-wrap: wrap; gap: .5rem 1rem; }
  main { width: calc(100% - 2rem); padding-block: 2rem; }
  .account-main.wide { width: calc(100% - 2rem); padding-block: 1.5rem; }
  .palette-grid { grid-template-columns: repeat(auto-fill, minmax(2.2rem, 1fr)); gap: .4rem; }
}

/* ---- learning statistics ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: .75rem; margin: 1.25rem 0 2rem; }
.stat-card { margin: 0; padding: 1rem; border: 1px solid #d5e2d2; border-radius: .75rem; background: #fff; }
.stat-label { display: block; margin-bottom: .35rem; color: #4d655a; font-size: .8rem; }
.stat-card strong { font-size: 1.35rem; line-height: 1.25; }
.stats-section { margin-top: 1.75rem; }
.stats-section h2 { margin-bottom: .35rem; }
.stats-section p { color: #4d655a; }
.stats-table { width: 100%; margin: .5rem 0 1.5rem; border-collapse: collapse; }
.stats-table th, .stats-table td { padding: .55rem .6rem; border-bottom: 1px solid #e7ece4; text-align: left; vertical-align: top; }
.stats-table th { color: #4d655a; font-size: .8rem; font-weight: 600; }
.stats-table td { line-height: 1.5; }
.trend-bar { display: inline-block; width: 6rem; height: .4rem; margin-left: .5rem; border-radius: 999px; background: #e7ece4; overflow: hidden; vertical-align: middle; }
.trend-bar > span { display: block; height: 100%; background: #275d45; }
.stats-notes { margin-top: 2rem; padding: 1rem 1.25rem; border: 1px solid #d5e2d2; border-radius: .75rem; background: #fff; }
.stats-notes h2 { margin-top: 0; }
.stats-notes ul { margin: .5rem 0 0; padding-left: 1.25rem; color: #4d655a; line-height: 1.7; }
@media (max-width: 640px) {
  .stats-table { display: block; overflow-x: auto; }
}

/* ---- cross-paper wrong questions ---- */
.wrong-filters { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem; margin: 1.25rem 0 1.5rem; }
.wrong-filters label { min-width: 8rem; color: #4d655a; font-size: .85rem; }
.wrong-filters select { margin-top: .25rem; }
.wrong-filters button { align-self: end; }
.wrong-toggle { display: flex; align-items: center; gap: .4rem; }
.wrong-paper { margin-top: 1.75rem; }
.wrong-paper h2 { font-size: 1.05rem; }
.wrong-item { align-items: flex-start; }
.wrong-item .practice-actions { margin-top: 0; }
.wrong-item .practice-actions form { margin: 0; }
@media (max-width: 640px) {
  .wrong-filters label { min-width: 100%; }
  .wrong-item { flex-direction: column; }
}

/* ---- mobile / PWA ---- */
@media (max-width: 520px) {
  button, .palette-jump { min-height: 44px; }
  button { min-width: 44px; }
  input:not([type="hidden"]):not([type="checkbox"]), textarea, select { font-size: 16px; }
  .audit-table, .stats-table { display: block; overflow-x: auto; }
  .practice-actions { gap: .5rem; }
  .palette-grid { grid-template-columns: repeat(auto-fill, minmax(2.6rem, 1fr)); }
}

/* ---- source verification workbench + publish checklist ---- */
.success { color: #275d45; font-weight: 600; }
.workbench-summary, .workbench-bulk { max-width: none; margin-top: 1.5rem; }
.bulk-fill { display: grid; gap: .75rem 1rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); margin-top: .75rem; }
.bulk-overwrite { align-content: end; }
.source-table, .checklist-table { width: 100%; margin: .5rem 0 1.75rem; border-collapse: collapse; }
.source-table th, .checklist-table th { padding: .45rem .5rem; border-bottom: 1px solid #d5e2d2; color: #4d655a; font-size: .78rem; font-weight: 600; text-align: left; }
.source-table td, .checklist-table td { padding: .45rem .5rem; border-bottom: 1px solid #e7ece4; font-size: .9rem; text-align: left; vertical-align: top; }
.source-table input[type="text"], .source-table input[type="date"], .source-table textarea { width: 100%; padding: .35rem .4rem; font-size: .85rem; }
.source-table textarea { min-height: 2.4rem; resize: vertical; }
.source-table .check-cell { width: 3rem; text-align: center; }
.source-table .check-cell input, .bulk-overwrite input { width: auto; }
.source-table small { color: #4d655a; }
.checklist-meta { color: #4d655a; font-size: .9rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1rem; }
.blocker-list { margin: .5rem 0 1.5rem; padding-left: 1.25rem; color: #a32922; line-height: 1.7; }
@media (max-width: 640px) {
  .source-table, .checklist-table { display: block; overflow-x: auto; }
  .bulk-fill { grid-template-columns: 1fr; }
}
@media print {
  .site-header, body > footer, .no-print, .back-link { display: none !important; }
  main { width: auto; margin: 0; padding: 0; }
  .notice { max-width: none; margin: 0 0 1rem; padding: 0; border: 0; }
  .checklist-table { page-break-inside: auto; }
  .checklist-table tr { page-break-inside: avoid; }
  h1 { font-size: 1.6rem; }
}
