:root {
  color-scheme: light;
  --ink: #22212a;
  --muted: #615d69;
  --surface: #fff;
  --background: #f7f7fa;
  --line: #e2e0e7;
  --brand: #701519;
  --brand-hover: #551013;
  --brand-light: #f9eeef;
  --radius: 16px;
  font-family: Inter, "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--background);
  line-height: 1.6;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; }
body, h1, h2, h3, p, dl, dd { margin: 0; }
button, input, select, textarea { font: inherit; }
button, a { touch-action: manipulation; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 3px solid #a34353; outline-offset: 3px; }
img { display: block; max-width: 100%; }
main { min-height: calc(100vh - 164px); }

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.site-header-inner, .shell, .site-footer > div {
  max-width: 1176px;
  margin-inline: auto;
  padding-inline: 32px;
}
.site-header-inner {
  min-height: 76px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}
.brand { display: inline-flex; align-items: center; gap: 16px; }
.brand img { width: 128px; height: auto; }
.brand span { border-left: 1px solid var(--line); padding-left: 16px; color: var(--muted); font-size: .9375rem; }
.quiet-link, .text-button { color: var(--brand); font-size: .9375rem; font-weight: 600; }
.quiet-link:hover, .text-button:hover { text-decoration: underline; }
.text-button { border: 0; background: transparent; display: block; margin: 12px auto 0; min-height: 42px; }
.site-footer { color: var(--muted); font-size: .875rem; }
.site-footer > div { padding-block: 22px; }

.start-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  column-gap: clamp(42px, 7vw, 108px);
  align-items: start;
  padding-block: clamp(34px, 5.8vw, 76px);
}
.intro { max-width: 560px; }
.section-label, .system-context {
  color: var(--brand);
  font-size: .9375rem;
  font-weight: 700;
}
.system-context { letter-spacing: .09em; }
.intro h1 { font-size: clamp(2.25rem, 4.22vw, 3.35rem); line-height: 1.24; letter-spacing: -.035em; margin-block: 8px 22px; font-weight: 800; }
.intro h1 span { color: var(--brand); }
.exam-picker h2 { font-size: .9375rem; margin-bottom: 8px; }
.subject-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.subject-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 6px 10px;
  font-weight: 700;
  text-align: left;
}
.subject-option[aria-pressed="true"] { color: var(--brand); border-color: var(--brand); background: var(--brand-light); }
.subject-option:disabled { opacity: 1; color: var(--muted); background: transparent; }
.subject-option span { font-size: .8125rem; font-weight: 500; white-space: nowrap; }
.paper-info { margin-top: 9px; padding: 14px; border-radius: 10px; }
.paper-info .field { margin-bottom: 10px; }
.paper-title { color: var(--ink); font-size: .9375rem; font-weight: 650; overflow-wrap: anywhere; }
.paper-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 12px;
  padding: 11px 0 0;
  border-top: 1px solid var(--line);
}
.paper-stats > div { min-width: 0; padding-inline: 17px; border-right: 1px solid var(--line); }
.paper-stats > div:first-child { padding-left: 0; }
.paper-stats > div:last-child { border: 0; }
.paper-stats dt { color: var(--muted); font-size: .875rem; line-height: 1.4; }
.paper-stats dd { font-size: clamp(1.25rem, 2.4vw, 1.65rem); line-height: 1.32; font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
.paper-stats dd span { font-size: .875rem; font-weight: 500; color: var(--muted); }
.intro-note { margin-top: 16px; font-size: .875rem; color: var(--muted); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.registration {
  padding: clamp(22px, 3.5vw, 36px);
  border-top: 4px solid var(--brand);
  box-shadow: 0 14px 40px #29233e0b;
}
.registration h2 { margin-bottom: 22px; font-size: 1.6rem; line-height: 1.3; }
.ready h2 { margin-top: 8px; margin-bottom: 10px; }
.ready-note { color: var(--muted); margin-bottom: 24px; }
.field { display: grid; gap: 7px; margin: 0 0 16px; font-size: .9375rem; font-weight: 650; min-width: 0; }
.class-field { padding: 0; border: 0; }
.class-field legend { padding: 0 0 7px; }
.class-controls { display: grid; grid-template-columns: minmax(112px, 0.9fr) minmax(0, 1.4fr); gap: 10px; }
.class-input { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: white; min-width: 0; }
.class-input input:not([type=radio]) { border: 0; width: 100%; min-width: 0; padding-inline: 0; }
.class-input input:focus-visible { outline: none; }
.class-input:focus-within { outline: 3px solid #a34353; outline-offset: 3px; }
.class-input span { padding-right: 7px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.class-input .class-prefix { padding: 0 0 0 5px; }
input:where(:not([type=radio], [type=checkbox])), select, textarea {
  padding: 10px 12px;
  min-height: 46px;
  border: 1px solid #ccc8d2;
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font-size: 1rem;
  font-weight: 400;
  min-width: 0;
}
input::placeholder, textarea::placeholder { color: #716d79; opacity: 1; }
select {
  appearance: none;
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, #706b76 50%), linear-gradient(135deg, #706b76 50%, transparent 50%);
  background-size: 6px 6px;
  background-position: right 16px center, right 10px center;
  background-repeat: no-repeat;
}
.field-note { margin: 4px 0 14px; font-size: .875rem; color: var(--muted); }
.form-error { color: #931f2d; font-size: .9375rem; overflow-wrap: anywhere; margin-block: 8px; }
.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 48px;
  padding: 9px 20px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 650;
  text-align: center;
  line-height: 1.4;
}
.button:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }
.button.secondary { background: var(--surface); color: var(--brand); border-color: #cfc4ca; }
.button.secondary:hover:not(:disabled) { background: var(--brand-light); border-color: var(--brand); }
.button.small { min-height: 42px; padding-inline: 13px; font-size: .9375rem; }
.button.full { width: 100%; }

#exam { padding-block: 20px 36px; }
.exam-toolbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 18px;
  padding: 12px 18px;
}
.exam-toolbar strong { display: block; line-height: 1.4; }
#saved-status { display: block; color: var(--muted); font-size: .8125rem; }
.timer {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: 1.35rem;
  color: var(--brand);
  background: var(--brand-light);
  padding: 3px 12px;
  border-radius: 7px;
}
.exam-layout { display: grid; grid-template-columns: minmax(0, 1fr) 254px; align-items: start; gap: 18px; margin-top: 18px; }
.exam-content { min-width: 0; display: grid; gap: 14px; }
.group-head, .passage, .question, .answer-card, .explanations { padding: 18px 22px; }
.group-head { border-left: 4px solid var(--brand); }
.group-head h1 { font-size: 1.5rem; margin-bottom: 4px; }
.group-head p { color: var(--muted); white-space: pre-line; }
.passage > summary, .answer-card summary, .explanation-item summary { cursor: pointer; color: var(--brand); font-weight: 650; }
#passage-text { margin-top: 12px; overflow-wrap: anywhere; }
#passage-text > p + p { margin-top: 11px; }
#passage-text mark { color: var(--brand); background: var(--brand-light); border-radius: 4px; padding-inline: 4px; }
.option-bank { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 12px; display: grid; gap: 5px; }
.question-list { display: grid; gap: 12px; }
.question { scroll-margin-top: 120px; border: 1px solid var(--line); margin: 0; min-width: 0; }
.question h2 { font-size: 1.075rem; line-height: 1.55; margin-bottom: 10px; white-space: pre-line; }
.question-points { font-size: .875rem; color: var(--muted); font-weight: 500; margin-left: 8px; white-space: nowrap; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.options.bank { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.choice {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 10px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.choice input { flex-shrink: 0; margin: 0; accent-color: var(--brand); }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-light); }
.choice .option-letter { font-weight: 700; }
.choice:focus-within { outline: 2px solid var(--brand); outline-offset: 1px; }
.question .fill-answer { width: min(100%, 360px); }
.question textarea { resize: vertical; width: 100%; min-height: 220px; }
.question textarea.short-answer { min-height: 100px; }
.answer-card { position: sticky; top: 90px; padding: 16px; }
.answer-card summary { display: flex; list-style: none; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.answer-card summary span { color: var(--muted); font-weight: 500; }
.number-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; margin-bottom: 14px; }
.number-grid button { padding: 0; border: 1px solid var(--line); border-radius: 6px; background: white; min-height: 34px; color: var(--muted); font-size: .875rem; }
.number-grid button.answered { background: var(--brand-light); color: var(--brand); font-weight: 700; }
.number-grid button.partly-answered { background: #fff4df; color: #674000; }
.number-grid button.current { border-color: var(--brand); }
.exam-navigation, .result-actions, .dialog-actions { display: flex; justify-content: space-between; gap: 10px; }

.result-shell { max-width: 818px; margin-inline: auto; padding-block: 40px; display: grid; gap: 14px; }
.score-panel { padding: 26px; border-top: 4px solid var(--brand); }
.score-panel h1 { font-size: clamp(1.65rem, 5vw, 2.1rem); line-height: 1.35; margin-top: 4px; }
.score-display, .dialog-score { color: var(--brand); font-variant-numeric: tabular-nums; }
.score-display strong { font-size: clamp(3.25rem, 10vw, 4.8rem); line-height: 1.08; }
.score-display span { margin-left: 8px; color: var(--muted); }
.score-note { margin-top: 7px; }
.result-parts { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; margin: 18px 0 10px; }
.result-parts > div { background: var(--background); border-radius: 8px; padding: 9px; }
.result-parts dt { color: var(--muted); font-size: .875rem; white-space: nowrap; }
.result-parts dd { font-weight: 700; }
.essay-feedback { padding-top: 14px; border-top: 1px solid var(--line); margin-top: 12px; }
.essay-feedback h2, .contact-panel h2 { font-size: 1.2rem; }
.essay-feedback p { margin-top: 5px; white-space: pre-wrap; }
.contact-panel { display: flex; align-items: center; justify-content: space-between; gap: 22px; padding: 20px 26px; }
.contact-panel p { color: var(--muted); margin-top: 6px; }
.contact-panel img { width: min(238px, 45%); height: auto; border: 1px solid var(--line); border-radius: 9px; }
.result-actions { flex-wrap: wrap; }
.result-actions > button { flex: 1 1 auto; }
.explanations h2, .admin-results h2 { font-size: 1.3rem; margin-bottom: 10px; }
.explanation-item { border-bottom: 1px solid var(--line); padding: 10px 0; }
.explanation-item:last-child { border: 0; }
.explanation-item p { margin-top: 7px; white-space: pre-wrap; }
.recorded-answer { overflow-wrap: anywhere; }
.explanation-item summary span { color: var(--muted); font-weight: 500; margin-left: 10px; }

.dialog { width: min(440px, calc(100% - 24px)); border: 1px solid var(--line); border-radius: 16px; color: var(--ink); padding: 24px; }
.dialog::backdrop { background: #231b2c87; }
.dialog h2 { font-size: 1.4rem; }
.dialog p { margin-block: 9px 14px; }
.dialog-score { font-size: 2.4rem; font-weight: 800; }

.admin-shell { padding-block: 34px; }
.admin-login { max-width: 420px; margin: 28px auto; }
.admin-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.admin-top h1 { font-size: clamp(1.5rem, 4vw, 2rem); }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin: 0 0 14px; }
.admin-stats > div { padding: 12px 14px; }
.admin-stats dt { font-size: .875rem; color: var(--muted); }
.admin-stats dd { font-weight: 800; font-size: 1.45rem; }
.admin-results { padding: 18px; margin-bottom: 13px; overflow-wrap: anywhere; }
.search-row { display: flex; gap: 8px; flex-wrap: wrap; margin-block: 8px 14px; }
.search-row input { flex: 1; }
.table-wrap { overflow: auto; }
table.records { width: 100%; border-collapse: collapse; text-align: left; font-size: .9375rem; }
.records th { background: var(--background); color: var(--muted); font-weight: 650; }
.records th, .records td { border-block-end: 1px solid var(--line); padding: 9px 10px; }
.records th:first-child, .records td:first-child { padding-left: 12px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.empty-note { padding: 14px 0; color: var(--muted); }
.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 11px; }
.detail-meta, .review-note { margin-bottom: 12px; color: var(--muted); }
.review-editor, .essay-text { background: var(--background); border-radius: 9px; padding: 14px; margin-block: 14px; }
.review-editor label { max-width: 620px; }
.essay-text p { white-space: pre-wrap; }
.admin-warning { border-left: 3px solid var(--brand); background: var(--brand-light); padding: 10px 13px; margin-bottom: 12px; }

.katex { font-size: 1.06em; }
/* Size short vector arrows against their overlay rather than the zero-width accent anchor. */
.katex .katex-overlay { position: relative; }
.inline-formula { white-space: nowrap; }
.question-figure { width: auto; max-height: 250px; margin-block: 12px 16px; }
.answer-parts { display: grid; gap: 11px; margin-top: 12px; }
.answer-part { border: 1px solid var(--line); border-radius: 9px; background: #fcfbfc; padding: 12px 14px; }
.answer-part h3 { font-size: 1rem; line-height: 1.65; margin-bottom: 6px; }
.photo-tools, .answer-modes, .formula-keys { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.answer-modes { margin: 2px 0 14px; }
.answer-modes button[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-light); }
.photo-picker { position: relative; cursor: pointer; }
.photo-picker:focus-within { outline: 3px solid #a34353; outline-offset: 3px; }
.photo-picker.at-limit { opacity: .58; cursor: default; }
.photo-file { position: absolute; width: 1px; height: 1px; padding: 0 !important; min-height: 1px !important; opacity: 0; left: 0; }
.photo-state { font-size: .875rem; color: var(--muted); }
.photo-state.complete { color: #196342; font-weight: 600; }
.photo-list { display: flex; flex-wrap: wrap; gap: 9px; }
.photo-list:not(:empty) { margin-block: 8px 11px; }
.photo-tile { display: grid; gap: 3px; justify-items: center; }
.photo-preview {
  display: block;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  width: 88px;
  height: 78px;
  overflow: hidden;
  background: white;
}
.photo-preview img { width: 100%; height: 100%; object-fit: contain; }
.photo-remove { border: 0; background: transparent; color: var(--brand); font-size: .8125rem; min-height: 28px; }
.photo-dialog { width: min(820px, calc(100% - 24px)); }
.photo-dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.photo-dialog > img { max-height: 72vh; margin: auto; object-fit: contain; }
.formula-keys { margin-top: 8px; gap: 5px; }
.formula-keys > button { color: var(--brand); background: white; border: 1px solid var(--line); border-radius: 6px; min-height: 34px; padding: 3px 8px; font-size: .875rem; }
.result-subparts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 5px; margin-bottom: 14px; }
.result-subparts > div { background: var(--background); border-radius: 6px; padding: 6px 8px; }
.result-subparts dt, .result-subparts dd { font-size: .875rem; }
.result-subparts dd { color: var(--brand); font-weight: 650; }
.review-rubric { margin-bottom: 12px; }
.review-rubric summary { cursor: pointer; color: var(--brand); }
.review-rubric p { margin-block: 5px; white-space: pre-wrap; }

@media (max-width: 820px) {
  .site-header-inner, .shell, .site-footer > div { padding-inline: 20px; }
  .start-layout { column-gap: 26px; }
  .exam-layout { grid-template-columns: minmax(0, 1fr); }
  .answer-card { position: static; }
  .number-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); }
  .records th, .records td { min-width: 105px; }
}

@media (max-width: 600px) {
  .site-header-inner, .shell, .site-footer > div { padding-inline: 16px; }
  .site-header-inner { min-height: 64px; }
  .brand { gap: 10px; }
  .brand img { width: 103px; }
  .brand span { padding-left: 10px; font-size: .875rem; }
  .start-layout { grid-template-columns: minmax(0, 1fr); row-gap: 22px; padding-block: 24px 32px; }
  .intro h1 { margin-block: 7px 16px; font-size: clamp(1.8rem, 7.7vw, 2.55rem); }
  .intro h1 br { display: none; }
  .intro h1 span { display: block; }
  .paper-title { font-size: .9375rem; }
  .paper-stats { margin-top: 10px; padding-top: 9px; }
  .paper-stats > div { padding-inline: 11px; }
  .intro-note { margin-top: 11px; }
  .registration h2 { margin-bottom: 17px; }
  #exam { padding-block: 12px 24px; }
  .exam-toolbar { gap: 7px; padding: 8px; }
  .exam-toolbar strong { font-size: .875rem; }
  #saved-status { font-size: .75rem; }
  .timer { font-size: 1.125rem; padding-inline: 8px; }
  #pause-exam { padding-inline: 8px; font-size: .875rem; }
  .exam-layout { gap: 10px; margin-top: 10px; }
  .exam-content { gap: 10px; }
  .group-head, .passage, .question, .answer-card, .explanations { padding: 12px; }
  .options { grid-template-columns: 1fr; }
  .options.bank { gap: 3px; }
  .options.bank .choice { padding-inline: 5px; gap: 4px; }
  .number-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .result-shell, .admin-shell { padding-block: 20px; }
  .score-panel, .contact-panel { padding: 16px; }
  .result-parts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .contact-panel { flex-direction: column; align-items: flex-start; }
  .contact-panel img { width: min(240px, 100%); align-self: center; }
  .admin-top { align-items: flex-start; flex-direction: column; }
  .admin-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-results { padding: 13px; }
}
