:root {
  --ink: #18243a;
  --ink-soft: #526078;
  --paper: #fbfcf8;
  --paper-cool: #eef2f7;
  --rule: #d6dde7;
  --blue: #24577b;
  --blue-dark: #163b56;
  --ochre: #d7a23a;
  --ochre-soft: #f4e7c9;
  --teal: #2c6d68;
  --danger: #a84538;
  --danger-soft: #f7e5e1;
  --success: #2d6a4f;
  --success-soft: #e5f1e9;
  --shadow: 0 16px 44px rgba(25, 39, 64, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(36, 87, 123, 0.035) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(rgba(36, 87, 123, 0.03) 1px, transparent 1px) 0 0 / 34px 34px,
    var(--paper-cool);
  color: var(--ink);
  font-family: "Aptos", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 76px 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 26px;
  background: var(--ink);
  color: #fff;
  border-bottom: 4px solid var(--ochre);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.42);
  color: var(--ochre);
  font: 700 21px/1 Georgia, "Microsoft YaHei", serif;
  transform: rotate(-2deg);
}

.brand-title,
.brand-subtitle {
  margin: 0;
}

.brand-title {
  font: 700 18px/1.2 Georgia, "Microsoft YaHei", serif;
  letter-spacing: 0.02em;
}

.brand-subtitle {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.timer {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.22);
  border-right: 1px solid rgba(255, 255, 255, 0.22);
}

.timer-label {
  color: rgba(255, 255, 255, 0.62);
  font-size: 11px;
}

.timer strong {
  color: #fff;
  font: 700 22px/1 Georgia, serif;
  font-variant-numeric: tabular-nums;
}

.timer.warning strong {
  color: #ffd37b;
}

.quiet-button,
.primary-button,
.filter-button,
.icon-button,
.danger-link {
  border: 0;
  background: none;
}

.quiet-button,
.primary-button {
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid currentColor;
  font-weight: 700;
}

.topbar .quiet-button {
  color: rgba(255, 255, 255, 0.8);
}

.topbar-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
}

.topbar .primary-button {
  color: var(--ink);
  background: var(--ochre);
  border-color: var(--ochre);
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 226px minmax(0, 1fr);
}

.section-rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 24px 18px;
  background: #f4f6f9;
  border-right: 1px solid var(--rule);
}

.rail-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  color: var(--ink-soft);
  font-size: 12px;
}

.rail-heading strong {
  color: var(--blue);
  font-size: 12px;
}

#section-nav {
  display: grid;
  gap: 5px;
}

.section-link {
  position: relative;
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 9px;
  align-items: center;
  width: 100%;
  padding: 11px 10px 11px 12px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-soft);
  text-align: left;
}

.section-link::before {
  position: absolute;
  inset: 7px auto 7px 0;
  width: 3px;
  background: transparent;
  content: "";
}

.section-link.active {
  color: var(--ink);
  background: #fff;
}

.section-link.active::before {
  background: var(--ochre);
}

.section-link strong {
  color: var(--blue);
  font: 700 11px/1 Georgia, serif;
  white-space: nowrap;
}

.section-link span {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-link em {
  color: var(--ink-soft);
  font-size: 11px;
  font-style: normal;
}

.rail-note {
  margin-top: auto;
  padding: 16px 2px 0;
  border-top: 1px solid var(--rule);
}

.rail-note-title {
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
}

.rail-note p {
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.65;
}

.paper-panel {
  min-width: 0;
  overflow: auto;
  padding: 28px clamp(24px, 4vw, 56px) 80px;
}

.grader-panel {
  min-width: 0;
  overflow: auto;
  padding: 32px clamp(24px, 4vw, 60px) 64px;
}

.mode-chip {
  padding: 7px 10px;
  color: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 11px;
}

.intake-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  padding-bottom: 20px;
  border-bottom: 3px double var(--ink);
}

.intake-head h1 {
  max-width: 780px;
  margin: 0;
  font: 700 clamp(28px, 3.2vw, 44px)/1.12 Georgia, "Microsoft YaHei", serif;
}

.exam-facts {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
  max-width: 360px;
}

.exam-facts span {
  padding: 6px 9px;
  color: var(--blue);
  background: var(--ochre-soft);
  font-size: 11px;
  font-weight: 800;
}

.drop-zone {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  margin-top: 24px;
  padding: 28px;
  border: 1.5px dashed var(--blue);
  background: rgba(255, 255, 255, 0.62);
  outline: none;
}

.drop-zone:focus-visible,
.drop-zone.dragging {
  border-color: var(--ochre);
  box-shadow: 0 0 0 3px rgba(215, 162, 58, 0.22);
  background: #fff;
}

.drop-mark {
  width: 76px;
  height: 88px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--blue);
  font: 700 17px/1 Georgia, serif;
  clip-path: polygon(0 0, 74% 0, 100% 24%, 100% 100%, 0 100%);
}

.drop-zone strong {
  display: block;
  font: 700 20px/1.25 Georgia, "Microsoft YaHei", serif;
}

.drop-zone p {
  max-width: 700px;
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.65;
}

.drop-zone .quiet-button {
  color: var(--blue);
  background: #fff;
}

.upload-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.upload-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule);
  background: rgba(255, 255, 255, 0.48);
}

.upload-type {
  color: var(--blue);
  font: 700 10px/1 Georgia, serif;
}

.upload-name {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-size {
  color: var(--ink-soft);
  font-size: 11px;
}

.grade-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 24px;
  padding: 18px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.action-label {
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
}

.grade-actions p {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
}

.large-button {
  min-width: 190px;
  min-height: 48px;
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
  font-size: 14px;
}

.large-button:disabled {
  cursor: default;
  opacity: 0.42;
}

.method-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 28px;
  border-top: 1px solid var(--rule);
}

.method-strip div {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 16px 14px 16px 0;
  border-right: 1px solid var(--rule);
}

.method-strip div:last-child {
  border-right: 0;
}

.method-strip strong {
  color: var(--ochre);
  font: 700 17px/1 Georgia, serif;
}

.method-strip span {
  color: var(--ink-soft);
  font-size: 12px;
}

.paper-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
  padding-bottom: 18px;
  border-bottom: 3px double var(--ink);
}

.paper-kicker {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
}

.paper-head h1 {
  margin: 0;
  font: 700 clamp(24px, 3vw, 38px)/1.15 Georgia, "Microsoft YaHei", serif;
}

.section-instruction {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.65;
}

.progress-block {
  width: 150px;
  flex: none;
  color: var(--ink-soft);
  font-size: 11px;
  text-align: right;
}

.progress-track {
  height: 4px;
  margin-top: 8px;
  overflow: hidden;
  background: var(--rule);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--ochre);
  transition: width 180ms ease;
}

.question-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(15, auto);
  grid-auto-flow: column;
  column-gap: clamp(28px, 4vw, 64px);
  row-gap: 0;
  padding-top: 8px;
}

.question-item {
  min-width: 0;
  padding: 14px 0 12px;
  border-bottom: 1px solid var(--rule);
}

.question-label {
  display: grid;
  grid-template-columns: 31px minmax(0, 1fr);
  gap: 10px;
  min-height: 43px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
}

.question-number {
  height: 24px;
  display: grid;
  place-items: center;
  color: var(--blue);
  background: var(--ochre-soft);
  font: 700 11px/1 Georgia, serif;
}

.question-text u {
  text-decoration-color: var(--ochre);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.answer-input {
  width: 100%;
  margin-top: 8px;
  padding: 9px 3px 7px;
  border: 0;
  border-bottom: 1.5px solid var(--blue);
  border-radius: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
}

.answer-input:focus {
  border-bottom-color: var(--ochre);
  box-shadow: 0 3px 0 -1px var(--ochre);
}

.answer-input:not(:placeholder-shown) {
  background: linear-gradient(transparent 72%, rgba(215, 162, 58, 0.16) 72%);
}

.answer-input::placeholder {
  color: #a1a9b6;
}

textarea.answer-input {
  min-height: 58px;
  resize: vertical;
  line-height: 1.45;
}

.modal {
  width: min(680px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(17, 27, 45, 0.62);
}

.modal-panel,
.result-panel {
  background: var(--paper);
  color: var(--ink);
}

.modal-panel {
  padding: 26px;
}

.modal-head,
.result-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.modal-head h2,
.result-heading h2 {
  margin: 0;
  font: 700 26px/1.15 Georgia, "Microsoft YaHei", serif;
}

.icon-button {
  width: 32px;
  height: 32px;
  color: var(--ink-soft);
  font-size: 25px;
  line-height: 1;
}

.modal-copy {
  margin: 20px 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.7;
}

.field-label {
  display: block;
  margin: 16px 0 7px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.text-field {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  outline: none;
  background: #fff;
  color: var(--ink);
}

.text-field:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(36, 87, 123, 0.14);
}

.field-hint {
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
}

.modal-actions .primary-button {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.danger-link {
  padding: 8px 0;
  color: var(--danger);
  font-size: 12px;
}

.result-modal {
  width: min(1040px, calc(100vw - 28px));
}

.result-panel {
  max-height: calc(100vh - 28px);
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.result-top {
  padding: 24px 26px 18px;
  border-bottom: 3px double var(--ink);
}

.score-medallion {
  width: 104px;
  height: 104px;
  display: grid;
  place-items: center;
  align-content: center;
  flex: none;
  border: 6px double var(--blue);
  border-radius: 50%;
  background: #fff;
  transform: rotate(-2deg);
}

.score-medallion strong {
  font: 700 40px/1 Georgia, serif;
}

.score-medallion span {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 12px;
}

.result-heading {
  flex: 1;
}

.result-score-column {
  display: grid;
  justify-items: center;
  gap: 7px;
  flex: none;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 800;
}

.result-heading p:last-child {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.6;
}

.section-score-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-bottom: 1px solid var(--rule);
}

.section-score {
  padding: 13px 16px;
  border-right: 1px solid var(--rule);
}

.section-score:last-child {
  border-right: 0;
}

.section-score span {
  display: block;
  color: var(--ink-soft);
  font-size: 11px;
}

.section-score strong {
  display: block;
  margin-top: 4px;
  color: var(--blue);
  font: 700 19px/1 Georgia, serif;
}

.result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--rule);
  background: #f4f6f9;
}

.result-filters,
.result-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-button {
  padding: 7px 11px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.filter-button.active {
  color: var(--blue);
  background: var(--ochre-soft);
}

.result-actions .quiet-button {
  color: var(--blue);
}

.result-actions .primary-button {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
}

.result-actions .primary-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.result-list {
  min-height: 0;
  overflow: auto;
  padding: 0 24px 28px;
}

.result-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) minmax(140px, 0.55fr);
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--rule);
}

.result-number {
  width: 38px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--blue);
  font: 700 18px/1 Georgia, serif;
}

.result-number.wrong-ring {
  color: var(--danger);
  border: 2px solid var(--danger);
  border-radius: 52% 48% 45% 55%;
  transform: rotate(-4deg);
}

.result-question {
  margin-bottom: 7px;
  font-size: 13px;
  line-height: 1.55;
}

.result-answer-line {
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.55;
}

.result-answer-line strong {
  color: var(--ink);
}

.result-state {
  justify-self: end;
  min-width: 76px;
  padding: 5px 8px;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
}

.result-state.correct {
  color: var(--success);
  background: var(--success-soft);
}

.result-state.wrong,
.result-state.blank {
  color: var(--danger);
  background: var(--danger-soft);
}

.result-state.review {
  color: #805d14;
  background: var(--ochre-soft);
}

.result-state.unreadable {
  color: #6d4a3c;
  background: #f3ece6;
}

.confidence-label {
  color: var(--ink-soft);
  font-size: 11px;
}

.result-reason {
  grid-column: 2 / 4;
  margin-top: -7px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.55;
}

.empty-state {
  padding: 54px 10px;
  color: var(--ink-soft);
  text-align: center;
  font-size: 14px;
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  display: grid;
  gap: 8px;
}

.toast {
  max-width: 360px;
  padding: 12px 15px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.5;
}

.toast.error {
  background: var(--danger);
}

.loading-line {
  height: 2px;
  background: var(--ochre);
  animation: loading 1.2s ease-in-out infinite alternate;
}

@keyframes loading {
  from {
    width: 18%;
  }
  to {
    width: 86%;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-rows: auto 1fr;
  }

  .topbar {
    padding: 14px 16px;
    flex-wrap: wrap;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .section-rail {
    padding: 12px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

  #section-nav {
    display: flex;
    overflow-x: auto;
  }

  .section-link {
    min-width: 170px;
    border-right: 1px solid var(--rule);
  }

  .rail-note {
    display: none;
  }

  .paper-panel {
    padding: 22px 18px 60px;
  }

  .grader-panel {
    padding: 22px 18px 48px;
  }

  .intake-head,
  .grade-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .exam-facts {
    justify-content: flex-start;
  }

  .drop-zone {
    grid-template-columns: 1fr;
  }

  .drop-mark {
    width: 58px;
    height: 68px;
  }

  .method-strip {
    grid-template-columns: 1fr 1fr;
  }

  .question-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-auto-flow: row;
  }

  .paper-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .progress-block {
    width: 100%;
    text-align: left;
  }

  .result-top,
  .result-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .result-score-column {
    justify-items: start;
  }

  .section-score-strip {
    grid-template-columns: 1fr;
  }

  .section-score {
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

  .result-row {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .result-state {
    grid-column: 2;
    justify-self: start;
  }

  .result-reason {
    grid-column: 2;
  }
}

@media print {
  body {
    background: #fff;
  }

  body > :not(#result-dialog) {
    display: none !important;
  }

  #result-dialog {
    position: static;
    width: auto;
    max-width: none;
    max-height: none;
    display: block;
    box-shadow: none;
  }

  #result-dialog::backdrop {
    display: none;
  }

  .result-panel {
    max-height: none;
  }

  .result-toolbar,
  .icon-button {
    display: none;
  }

  .result-list {
    overflow: visible;
  }
}
