:root {
  color-scheme: light;
  --background: #f2f4f7;
  --surface: #ffffff;
  --ink: #172234;
  --muted: #526178;
  --line: #dce2eb;
  --nav: #152237;
  --nav-ink: #f7f9fc;
  --gold: #efc262;
  --gold-light: #fff5dc;
  --focus: #79530c;
  --green: #20654b;
  --shadow: 0 2px 4px rgb(24 36 56 / 4%);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--background); color: var(--ink); line-height: 1.55; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
input, select, textarea { min-width: 0; }
input[type="checkbox"], input[type="radio"] { accent-color: #835b0b; width: 1.05rem; height: 1.05rem; margin: 0; }
select, textarea, input:not([type="hidden"], [type="checkbox"], [type="radio"], [type="file"]) {
  width: 100%; min-height: 2.62rem; color: var(--ink); background: var(--surface);
  border: 1px solid #c6d0dd; padding: .48rem .73rem; border-radius: 7px;
}
select {
  appearance: none;
  padding-right: 2rem;
  background-image: linear-gradient(45deg, transparent 48%, #5b687c 50%), linear-gradient(135deg, #5b687c 50%, transparent 52%);
  background-position: calc(100% - 1rem) 52%, calc(100% - .72rem) 52%;
  background-size: .28rem .28rem;
  background-repeat: no-repeat;
}
textarea { resize: vertical; }
input::placeholder { color: #607087; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1 { line-height: 1.24; font-size: clamp(1.65rem, 3vw, 2.1rem); letter-spacing: -.03em; }
h2 { line-height: 1.35; font-size: 1.14rem; }
fieldset { min-inline-size: 0; }
.quiet { color: var(--muted); }
.small-text { font-size: .875rem; }
.tabular { font-variant-numeric: tabular-nums; }
.centered { align-self: center; }
.visually-hidden, .copy-fallback {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.62rem;
  border: 1px solid transparent; border-radius: 7px; padding: .47rem .91rem;
  font-size: .9375rem; font-weight: 700; line-height: 1.35; color: var(--ink); text-decoration: none;
  white-space: nowrap;
}
.button.primary { background: var(--gold); border-color: #e6b44b; color: #2c210b; }
.button.primary:hover { background: #e7b348; }
.button.secondary { background: var(--surface); border-color: #c6d0dd; }
.button.secondary:hover { background: #edf1f6; }
.button.small { min-height: 2.15rem; padding: .3rem .62rem; font-size: .875rem; }
.text-button { border: 0; padding: 0; background: none; color: #36557f; font-size: .875rem; text-decoration: none; white-space: nowrap; }
.danger-text { color: #972d24; }
.text-button:hover, .back-link:hover { text-decoration: underline; }
.back-link { display: inline-block; margin-bottom: .85rem; color: #36557f; font-weight: 600; text-decoration: none; font-size: .9375rem; }
.alert { border: 1px solid; border-radius: 8px; padding: .72rem .88rem; font-size: .9375rem; }
.alert-success { background: #eaf6ee; color: #1a5b43; border-color: #bdddc9; }
.alert-error { background: #fff0ed; color: #932b20; border-color: #edb5aa; }
.alert-info { background: #eef4fb; color: #2b5078; border-color: #cbdced; }
.alert ul { margin-bottom: 0; }
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); max-width: calc(100% - 2rem);
  z-index: 5; background: var(--nav); color: var(--nav-ink); border: 1px solid #4a607c; border-radius: 8px;
  box-shadow: 0 7px 20px #15223730; padding: .75rem 1rem;
}

.brand { display: flex; gap: .65rem; align-items: center; line-height: 1.2; flex-shrink: 0; }
.brand-mark {
  display: grid; width: 2.55rem; height: 2.55rem; border-radius: 8px; place-items: center;
  background: var(--gold); color: #352809; font: 700 1.34rem "Songti SC", SimSun, serif;
}
.brand strong { display: block; color: var(--nav-ink); font-size: 1rem; letter-spacing: .04em; }
.brand div > span { display: block; margin-top: .24rem; color: #bdc9db; font-size: .8rem; }

.admin-shell { display: grid; grid-template-columns: 14rem minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; align-self: start; min-height: 100vh; background: var(--nav); color: var(--nav-ink); padding: 1.44rem 1.1rem; }
.sidebar .brand { margin: .28rem .28rem 2.45rem; }
.admin-nav { display: grid; gap: .33rem; }
.admin-nav a {
  display: flex; align-items: center; gap: .7rem; min-height: 2.85rem; padding: .59rem .74rem;
  color: #cfdaea; font-size: .9375rem; font-weight: 600; text-decoration: none;
  border: 1px solid transparent; border-radius: 7px;
}
.admin-nav a:hover { background: #23344c; color: #fff; }
.admin-nav a[aria-current="page"] { background: #2b3b50; border-color: #40516a; color: #ffdc8d; }
.side-icon { width: 1.15rem; display: inline-grid; place-items: center; font-family: sans-serif; font-size: 1.17rem; }
.topbar {
  min-height: 4.1rem; display: flex; justify-content: space-between; align-items: center; gap: .8rem;
  padding: .55rem clamp(1rem, 3.2vw, 3.15rem); background: var(--surface); border-bottom: 1px solid var(--line);
  color: var(--muted); font-size: .9rem;
}
.topbar strong { color: var(--ink); }
.breadcrumb-divider { margin-inline: .42rem; color: #6b7b92; }
.admin-content { width: 100%; max-width: 95rem; margin-inline: auto; padding: 1.85rem clamp(1rem, 3.2vw, 3.15rem) 3.5rem; }
.admin-content > .alert { margin-bottom: 1rem; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.35rem; }
.page-heading p { margin-top: .45rem; color: var(--muted); font-size: .9375rem; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem; margin-bottom: 1rem; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow); padding: .9rem 1rem; }
.stat-card > span { display: block; color: var(--muted); font-size: .875rem; }
.stat-card strong { display: block; margin-top: .18rem; color: var(--ink); font-size: clamp(1.35rem, 2.6vw, 2rem); line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-card .stats-caption { margin-top: .28rem; }
.stat-link { text-decoration: none; }
.stat-link:hover, .stat-link[aria-current="true"] { border-color: #a8791f; background: #fff9eb; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow); }
.admin-content > .panel + .panel { margin-top: 1rem; }
.padded-panel { padding: 1.25rem; }
.padded-panel h2 + p { margin-top: .4rem; }
.import-panel { margin-bottom: 1rem; }
.import-top { padding: 1.05rem 1.15rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.import-top p { max-width: 39rem; font-size: .875rem; color: var(--muted); margin-top: .32rem; }
.upload-form { display: flex; align-items: center; gap: .55rem; }
.file-picker { min-width: 0; }
.file-picker input { max-width: 15.6rem; width: 100%; color: var(--muted); font-size: .875rem; }
input::file-selector-button { background: #f5f7fa; border: 1px solid #c6d0dd; border-radius: 7px; font: inherit; color: var(--ink); padding: .49rem .65rem; margin-right: .55rem; cursor: pointer; }
.import-summary { padding: .66rem 1.15rem; border-top: 1px solid var(--line); background: #f9fafc; color: var(--muted); font-size: .875rem; border-radius: 0 0 9px 9px; }
.import-summary summary { cursor: pointer; }
.import-summary summary span { margin-left: .62rem; font-variant-numeric: tabular-nums; }
.import-totals { color: var(--ink); display: inline-block; }
.import-summary p { margin-top: .35rem; overflow-wrap: anywhere; }
.table-tools { padding: .85rem 1.15rem; display: flex; justify-content: space-between; align-items: center; gap: .72rem; }
.filters { display: flex; align-items: center; gap: .5rem; }
.filter-actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.filters input { max-width: 12rem; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .875rem; }
thead { background: #f5f7fa; color: #43536a; }
th, td { padding: .68rem .76rem; border-top: 1px solid #e5e9f0; vertical-align: middle; }
th:first-child, td:first-child { padding-left: 1.15rem; }
th:last-child, td:last-child { padding-right: 1.15rem; }
thead th { font-weight: 700; white-space: nowrap; }
tbody th { font-weight: 650; overflow-wrap: anywhere; min-width: 6rem; }
tbody tr:hover { background: #fcfbf8; }
.date-cell { white-space: nowrap; }
.roster-table { min-width: 50rem; }
.roster-platform { white-space: nowrap; }
.roster-platform-state { display: block; color: var(--muted); white-space: nowrap; }
.bank-table { min-width: 46rem; }
.bank-table th[scope="row"] { min-width: 16rem; }
.bank-table td { white-space: nowrap; }
.row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem; }
.pagination { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1.15rem; border-top: 1px solid #e5e9f0; color: var(--muted); font-size: .875rem; }
.pagination > div { display: flex; gap: .45rem; }
.empty-state { padding: 1.45rem 1.15rem; color: var(--muted); border-top: 1px solid var(--line); }
.status {
  display: inline-flex; align-items: center; gap: .35rem; min-height: 1.6rem; padding: .13rem .49rem;
  border-radius: 5px; line-height: 1.25; font-size: .875rem; font-weight: 650; white-space: nowrap;
}
.status-neutral { background: #edf0f4; color: #43536a; }
.status-accent { background: #e7eef9; color: #345780; }
.status-success { background: #e4f3ea; color: #216247; }
.status-warning { background: #fdf1d9; color: #744b13; }
.status-line { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: .65rem 0; }
.stack-form { display: grid; gap: 1rem; }
.inline-form { display: flex; align-items: end; gap: .6rem; margin: .8rem 0 .15rem; }
.inline-form .growing { flex: 1; }
.field { display: grid; gap: .32rem; font-size: .9375rem; font-weight: 650; }
.field input, .field select, .field textarea { font-weight: 400; }
.check { display: flex; align-items: center; gap: .58rem; font-size: .9375rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .62rem; }
.options-editor, .platform-fieldset { border: 0; padding: 0; margin: 0; }
.options-editor legend, .platform-fieldset legend { font-weight: 700; margin-bottom: .4rem; }
.answer-key-options { display: flex; flex-wrap: wrap; gap: .6rem; }
.answer-key-options .check { min-width: 3.3rem; border: 1px solid var(--line); padding: .5rem .65rem; border-radius: 7px; }
.answer-key-options .check:has(input:checked) { background: var(--gold-light); border-color: #e2c16e; }
.editor, .settings-panel { max-width: 52rem; }
.score-field { max-width: 12rem; }
.settings-divider { border-top: 1px solid var(--line); padding-top: .85rem; }
.settings-divider .check { margin-top: .6rem; }
.settings-panel .check + p { margin: .3rem 0 0 1.65rem; }
.settings-list { margin: .85rem 0 0; }
.settings-list > div { display: grid; grid-template-columns: minmax(5rem, 8rem) 1fr; gap: .5rem; padding: .57rem 0; border-bottom: 1px solid var(--line); }
.settings-list > div:last-child { border-bottom: 0; }
.settings-list dt { color: var(--muted); }
.settings-list dd { margin: 0; font-weight: 600; }

.exam-mast { background: var(--nav); color: var(--nav-ink); }
.exam-mast-inner { display: flex; justify-content: space-between; align-items: center; gap: 1rem; max-width: 72rem; padding: .69rem 1.25rem; min-height: 4.1rem; margin: auto; }
.mast-link { font-size: .9rem; text-decoration: none; color: #d9e3f2; }
.mast-link:hover { text-decoration: underline; }
.exam-mast :focus-visible, .sidebar :focus-visible { outline-color: #f5ca73; }
.center-column { width: min(100% - 2rem, 44rem); margin: clamp(1.25rem, 6vw, 4.85rem) auto 3rem; }
.center-column.compact-column { max-width: 30rem; }
.center-column > .alert { margin-bottom: 1rem; }
.entry-card {
  padding: clamp(1.2rem, 4.4vw, 2.2rem); background: var(--surface); border: 1px solid var(--line);
  border-top: 4px solid var(--gold); border-radius: 11px; box-shadow: 0 10px 22px #2539560b;
}
.entry-heading { margin-bottom: 1.3rem; }
.entry-heading p { color: var(--muted); margin-top: .55rem; }
.entry-heading { overflow-wrap: anywhere; }
.entry-card > .alert { margin-bottom: 1rem; }
.identity-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; padding: .8rem 1rem; margin: 0 0 1.2rem; border-radius: 8px; background: #f3f6fa; }
.identity-grid dt { color: var(--muted); font-size: .875rem; }
.identity-grid dd { margin: .12rem 0 0; font-weight: 700; overflow-wrap: anywhere; }
.exam-rules { display: flex; gap: .6rem 1rem; flex-wrap: wrap; font-size: .9375rem; margin-bottom: 1.1rem; }
.platform-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.platform-option { display: flex; align-items: center; gap: .7rem; cursor: pointer; border: 1px solid #c5d0de; border-radius: 8px; padding: .72rem .8rem; }
.platform-option:has(input:checked) { border-color: #ad7a16; background: #fff8e8; }
.platform-option small { display: block; color: var(--muted); font-size: .82rem; }
.paper-layout { display: grid; grid-template-columns: minmax(0, 1fr) 14rem; align-items: start; gap: 1rem; width: min(100% - 2rem, 69.5rem); margin: 1.3rem auto 3rem; }
.paper { grid-column: 1; grid-row: 1; padding: clamp(1rem, 4vw, 2.6rem); border-top: 4px solid var(--gold); }
.paper-index { grid-column: 2; grid-row: 1; position: sticky; top: 1rem; padding: 1rem; }
.index-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .85rem; gap: .5rem; }
.index-header span { color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.number-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .36rem; }
.number-link { display: grid; place-items: center; min-width: 0; min-height: 1.94rem; background: #f5f7fa; border: 1px solid #dce3ed; border-radius: 5px; font-size: .875rem; text-decoration: none; font-variant-numeric: tabular-nums; }
.number-link:hover { border-color: #806023; }
.number-link.answered { background: #e5eee9; border-color: #abc7b9; color: #1b5a43; font-weight: 700; }
.save-state { margin: .68rem 0 .2rem; color: var(--muted); font-size: .875rem; }
.index-submit { width: 100%; margin-top: .7rem; }
.paper-header { text-align: center; margin-bottom: 1.6rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.paper-platform { display: inline-block; background: var(--gold-light); padding: .18rem .62rem; border-radius: 5px; color: #684e1c; font-size: .875rem; font-weight: 700; margin-bottom: .5rem; }
.paper-header h1 { font-family: "Songti SC", SimSun, "Microsoft YaHei UI", serif; font-size: clamp(1.55rem, 4vw, 2.4rem); letter-spacing: .035em; }
.paper-header p { margin: .6rem 0 .86rem; color: var(--muted); font-size: .94rem; }
.paper-identity { display: flex; justify-content: center; flex-wrap: wrap; gap: .25rem 1.25rem; color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.paper-identity strong { color: var(--ink); margin-left: .3rem; }
.paper-section + .paper-section { margin-top: 1.2rem; }
.paper-section > h2 { border-left: 3px solid #d6a94e; background: #f5f7fa; padding: .55rem .7rem; border-radius: 0 5px 5px 0; }
.paper-section > h2 span { color: var(--muted); font-size: .875rem; font-weight: 400; margin-left: .32rem; white-space: nowrap; }
.multi-instruction { margin: .5rem 0 0 .7rem; }
.paper-question { border: 0; padding: 0 0 .88rem; margin: 1rem 0 0; border-bottom: 1px solid #e5eaf0; scroll-margin-top: .85rem; }
.paper-question:target { border-bottom-color: #c8a354; }
.paper-question legend { display: flex; gap: .4rem; max-width: 100%; padding: 0; font-weight: 700; overflow-wrap: anywhere; }
.question-no { min-width: 1.64rem; flex-shrink: 0; color: #44556e; font-variant-numeric: tabular-nums; }
.answer-options { display: grid; gap: .17rem; margin: .39rem 0 0 1.7rem; }
.answer-option { display: flex; align-items: baseline; gap: .51rem; padding: .39rem .55rem; cursor: pointer; border: 1px solid transparent; border-radius: 6px; }
.answer-option input { flex: 0 0 auto; align-self: flex-start; margin-top: .22rem; }
.answer-option:hover { background: #f4f7fa; }
.answer-option:has(input:checked) { background: #fff8e8; border-color: #efdaa4; }
.answer-letter { color: #536581; margin-right: .32rem; }
.paper-footer { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: 1.35rem; color: var(--muted); font-size: .9375rem; }
.paper-footer .button { min-width: 6rem; }
dialog { width: min(100% - 2rem, 26rem); border: 1px solid #b9c7d8; border-radius: 11px; padding: 0; box-shadow: 0 12px 40px #12223f33; color: var(--ink); }
dialog::backdrop { background: #16253985; }
.dialog-content { padding: 1.25rem; }
.dialog-content p { margin-top: .65rem; color: var(--muted); }
.dialog-actions { display: flex; justify-content: end; gap: .5rem; margin-top: 1.05rem; }
.export-dialog .stack-form { margin-top: .9rem; }
.export-dialog .dialog-actions { margin-top: 0; }
.result-card { text-align: center; }
.result-meta { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.55fr); margin: 1.25rem 0 0; text-align: left; }
.result-card > .quiet { margin-top: 1rem; }
.result-card a { margin-top: 1rem; }
.score-number { margin: .6rem 0 .48rem; font-variant-numeric: tabular-nums; }
.score-number strong { font-size: 3.6rem; line-height: 1; letter-spacing: -.05em; }
.score-number span { color: var(--muted); }
.review-card { margin-top: 1rem; }
.review-panel { max-width: 52rem; }
.review-item { border-top: 1px solid var(--line); padding: .95rem 0 .2rem; margin-top: .8rem; }
.review-item h3 { font-size: 1rem; }
.review-item p { margin-top: .35rem; }

@media (max-width: 1020px) {
  .admin-shell { grid-template-columns: 11.25rem minmax(0, 1fr); }
  .admin-content, .topbar { padding-inline: 1rem; }
  .import-top { align-items: flex-start; flex-direction: column; gap: .65rem; }
  .table-scroll table:not(.bank-table) { min-width: 42rem; }
}

@media (max-width: 680px) {
  .admin-shell { display: block; }
  .sidebar { position: static; min-height: 0; padding: .65rem .85rem .55rem; }
  .sidebar .brand { margin: 0 0 .62rem; }
  .admin-nav { display: flex; flex-wrap: wrap; gap: .28rem; }
  .admin-nav a { padding: .24rem .43rem; min-height: 2.08rem; gap: .27rem; font-size: .8725rem; }
  .topbar { min-height: 3rem; }
  .admin-content { padding: 1.18rem .7rem 2rem; }
  .page-heading { align-items: flex-start; gap: .45rem; }
  .stats { gap: .43rem; }
  .stat-card { padding: .63rem .55rem; }
  .table-tools, .import-top { padding-inline: .76rem; }
  .table-tools { flex-wrap: wrap; }
  .filters { flex-wrap: wrap; }
  .upload-form { width: 100%; flex-wrap: wrap; }
  .padded-panel { padding: .8rem; }
  .form-grid { gap: .45rem; }
  .paper-layout { display: flex; flex-direction: column; width: calc(100% - 1rem); margin-top: .65rem; gap: .65rem; }
  .paper-index { position: static; width: 100%; padding: .7rem .8rem; }
  .index-header { margin-bottom: .48rem; }
  .number-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); gap: .23rem; }
  .number-link { min-height: 1.9rem; }
  .index-submit { display: none; }
  .paper { width: 100%; padding: .8rem; }
  .paper-header { padding: .2rem .2rem .9rem; margin-bottom: 1rem; }
  .paper-section > h2 { font-size: 1rem; }
  .answer-options { margin-left: .48rem; }
  .answer-option { min-height: 2.55rem; }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

@media (max-width: 500px) {
  .result-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-submitted { grid-column: 1 / -1; }
}
