:root {
  --ink: #17202a;
  --ink-soft: #273445;
  --muted: #5d6c7d;
  --muted-strong: #425164;
  --line: #cfd8e3;
  --line-strong: #aebdcc;
  --surface: #eef2f6;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --accent: #176f68;
  --accent-strong: #0d5650;
  --accent-soft: #e7f4f1;
  --gold: #9a6a12;
  --gold-soft: #fff6df;
  --paper: #fff;
  --shadow: 0 10px 28px rgba(31, 42, 55, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #f7f9fb 0, var(--surface) 260px),
    var(--surface);
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.nancy-prep-shell {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  min-height: 100vh;
  align-items: start;
  min-width: 0;
}

.nancy-prep-workspace {
  min-height: 100vh;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  border: 1px solid var(--line);
  background: #eef3f7;
  padding: 4px;
}

.mode-switch button,
.secondary-button {
  min-height: 42px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-weight: 700;
  cursor: pointer;
}

.mode-switch button.active {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 4px 12px rgba(31, 42, 55, 0.16);
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 8px;
}

.secondary-button:disabled {
  border-color: #d6dee7;
  background: #edf1f5;
  color: #888;
  cursor: not-allowed;
}

.request-panel,
.style-panel,
.classroom-session-panel,
.materials-panel,
.profiles-panel,
.settings-panel,
.output-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.session-summary {
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  border-radius: 8px;
}

.recording-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
}

.recording-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.recording-timer {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
}

.request-actions {
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 8px;
}

.compact-status {
  padding: 7px 9px;
  color: #555;
  font-size: 12px;
}

.debug-panel[hidden] {
  display: none;
}

.request-panel label,
.panel-label,
.plan-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}

.request-panel textarea {
  width: 100%;
  resize: vertical;
  min-height: 128px;
  padding: 10px;
  border: 1px solid #bfb8aa;
  background: #fff;
  color: #222;
  font: 13px/1.45 Arial, "Microsoft YaHei", sans-serif;
}

.style-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.style-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  padding: 9px;
  border: 1px solid #d8d2c5;
  background: #fff;
  cursor: pointer;
}

.style-option input {
  margin-top: 2px;
}

.style-name {
  color: #222;
  font-size: 13px;
  font-weight: 700;
}

.style-detail {
  color: #666;
  font-size: 11.5px;
  line-height: 1.35;
}

.style-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.paste-zone {
  min-height: 86px;
  padding: 12px;
  border: 1px dashed var(--line-strong);
  background: #fff;
  color: var(--muted-strong);
  font-size: 12.5px;
  line-height: 1.4;
  outline: none;
  border-radius: 8px;
}

.paste-zone:focus,
.paste-zone.dragging {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(35, 77, 69, .14);
}

.file-button {
  display: grid;
  place-items: center;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 8px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.materials-list {
  display: grid;
  gap: 8px;
}

.material-item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid #d8d2c5;
  background: #fff;
}

.material-card {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
}

.analysis-box {
  display: grid;
  gap: 5px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.45;
  border-radius: 8px;
}

.analysis-box.pending {
  border-color: #d9c58f;
  background: var(--gold-soft);
}

.analysis-box.failed {
  border-color: #e1a3a3;
  background: #fff5f5;
}

.analysis-box p {
  margin: 0;
}

.material-card .material-item {
  padding: 0;
  border: 0;
}

.material-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border: 1px solid #ddd5c8;
  background: #f3f0e8;
}

.material-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid #ddd5c8;
  background: #f3f0e8;
  font-size: 11px;
  font-weight: 700;
}

.material-name {
  min-width: 0;
  overflow: hidden;
  color: #222;
  font-size: 12.5px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.material-meta {
  color: #666;
  font-size: 11.5px;
}

.remove-material {
  width: 28px;
  height: 28px;
  border: 1px solid #c8c0b3;
  background: #fff;
  color: #333;
  cursor: pointer;
}

.ocr-draft {
  display: grid;
  gap: 7px;
}

.ocr-draft label {
  color: #333;
  font-size: 12px;
  font-weight: 700;
}

.ocr-draft textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  padding: 8px;
  border: 1px solid #c8c0b3;
  background: #fff;
  color: #222;
  font: 12.5px/1.45 Arial, "Microsoft YaHei", sans-serif;
}

.material-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mini-button {
  min-height: 32px;
  border: 1px solid #bfb8aa;
  background: #fff;
  color: #222;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.mini-button.confirmed {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.material-status {
  color: #666;
  font-size: 11.5px;
}

.profile-note {
  color: #666;
  font-size: 12px;
  line-height: 1.35;
}

.profiles-list {
  display: grid;
  gap: 8px;
}

.profile-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  padding: 9px;
  border: 1px solid #d8d2c5;
  background: #fff;
  cursor: pointer;
}

.profile-option input {
  margin-top: 2px;
}

.profile-name {
  color: #222;
  font-size: 13px;
  font-weight: 700;
}

.profile-meta,
.profile-weakness {
  color: #666;
  font-size: 11.5px;
  line-height: 1.35;
}

.profile-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.plan-grid {
  display: grid;
  gap: 7px;
  font-size: 12.5px;
}

.plan-row {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 8px;
}

.plan-key {
  color: #666;
}

.plan-value {
  color: #111;
  font-weight: 700;
}

.status-line {
  padding: 8px 10px;
  border: 1px solid #d8d2c5;
  background: #fff;
  font-size: 12.5px;
  line-height: 1.4;
}

.qa-panel {
  padding-top: 14px;
  border-top: 1px solid #d8d2c5;
  color: #333;
  font-size: 13px;
  line-height: 1.45;
}

.qa-panel strong {
  display: block;
  margin-bottom: 6px;
}

.qa-panel .ok {
  color: #166534;
}

.qa-panel .warn {
  color: #9a3412;
}

.gate-list {
  display: grid;
  gap: 6px;
}

.gate-row {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 7px;
  align-items: start;
  padding: 7px 8px;
  border: 1px solid #d8d2c5;
  background: #fff;
  font-size: 12.5px;
  line-height: 1.35;
}

.gate-row.pass .gate-mark {
  color: #166534;
}

.gate-row.fail .gate-mark {
  color: #b91c1c;
}

.gate-title {
  font-weight: 700;
}

.gate-category {
  display: inline-block;
  margin-right: 5px;
  padding: 1px 5px;
  border: 1px solid #c8c0b3;
  color: #555;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.gate-detail {
  color: #666;
}

.gate-result {
  padding: 9px 10px;
  border: 1px solid #d8d2c5;
  background: #fff;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.35;
}

.gate-result.pass {
  color: #166534;
}

.gate-result.fail {
  color: #b91c1c;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(17, 17, 17, .42);
}

.dialog-backdrop[hidden] {
  display: none;
}

.loading-backdrop {
  z-index: 30;
}

.loading-dialog {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 14px;
  align-items: center;
  width: min(460px, 100%);
  padding: 22px 24px;
  border: 1px solid #c8c0b3;
  background: #fff;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .25);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

.loading-dialog strong,
.loading-dialog span {
  display: block;
}

.loading-dialog strong {
  margin-bottom: 5px;
  font-size: 17px;
}

.loading-dialog span {
  color: #555;
  font-size: 13px;
  line-height: 1.45;
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #d8d2c5;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .85s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.confirm-dialog {
  width: min(620px, 100%);
  max-height: 86vh;
  overflow: auto;
  padding: 24px;
  background: #fff;
  border: 1px solid #c8c0b3;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .25);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

.confirm-dialog h2 {
  margin: 0 0 16px;
  font-size: 22px;
}

.confirm-summary {
  display: grid;
  gap: 9px;
}

.confirm-lead {
  margin: 0;
  color: #333;
  font-size: 13px;
  line-height: 1.45;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.paper {
  width: 210mm;
  margin: 24px auto;
}

.page,
.paper-page {
  width: 210mm;
  min-height: 297mm;
  padding: 22mm 24mm 20mm;
  margin: 0 auto 18px;
  background: var(--paper);
  box-shadow: 0 2px 18px rgba(0, 0, 0, .16);
  page-break-after: always;
  position: relative;
}

.title-page {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.paper-title {
  font-size: 25px;
  font-weight: 700;
  line-height: 1.1;
}

.paper-subtitle,
.meta-line {
  font-size: 14px;
  color: var(--muted);
}

.student-fields {
  display: grid;
  grid-template-columns: 1.1fr .9fr .9fr;
  gap: 18px;
  margin-top: 10px;
  font-size: 15px;
}

.field-line {
  display: inline-block;
  min-width: 120px;
  border-bottom: 1px solid #111;
  transform: translateY(-2px);
}

.thin-rule {
  border: 0;
  border-top: 1px solid var(--rule);
  width: 100%;
  margin: 0;
}

.intro-block h2,
.question-section {
  font-size: 18px;
  margin: 0 0 10px;
}

.intro-block ul {
  margin: 0;
  padding-left: 20px;
  line-height: 1.5;
}

.question-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.question-number {
  font-size: 18px;
  font-weight: 700;
}

.marks {
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
}

.stem {
  font-size: 18px;
  line-height: 1.55;
  margin-bottom: 20px;
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px 24px;
  margin: 18px 0 24px;
  font-size: 17px;
}

.choice {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: start;
}

.workspace {
  margin-top: 22px;
  min-height: 112mm;
  border-top: 1px solid #777;
  border-bottom: 1px solid #bbb;
}

.workspace.compact {
  min-height: 72mm;
}

.solution {
  margin-top: 16px;
  font-size: 16.5px;
  line-height: 1.62;
}

.solution-label,
.teacher-note-label {
  font-weight: 700;
}

.teacher-note {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #999;
  font-size: 15.5px;
  line-height: 1.55;
}

.page-number {
  position: absolute;
  bottom: 10mm;
  left: 0;
  width: 100%;
  text-align: center;
  font-size: 12px;
  color: #555;
}

.katex-display {
  margin: .65em 0;
}

@media (max-width: 980px) {
  .nancy-prep-shell {
    grid-template-columns: 1fr;
  }

  .nancy-prep-sidebar {
    position: static;
    height: auto;
    max-height: none;
  }

  .paper,
  .page {
    width: min(100%, 210mm);
  }
}

@media print {
  @page {
    size: A4;
    margin: 0;
  }

  body {
    background: #fff;
  }

  .nancy-prep-sidebar {
    display: none;
  }

  .dialog-backdrop {
    display: none;
  }

  .nancy-prep-shell {
    display: block;
  }

  .paper {
    margin: 0;
    width: auto;
  }

  .page,
  .paper-page {
    box-shadow: none;
    margin: 0;
    width: 210mm;
    min-height: 297mm;
  }
}

.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.export-row .primary,
.export-row .small {
  min-width: 0;
}

.export-row {
  grid-template-columns: 1fr;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(17, 17, 17, .42);
}

.loading-overlay[hidden] {
  display: none;
}

.loading-box {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 14px;
  align-items: center;
  width: min(460px, 100%);
  padding: 22px 24px;
  border: 1px solid #c8c0b3;
  background: #fff;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .25);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

.loading-box strong,
.loading-box span {
  display: block;
}

.loading-box strong {
  margin-bottom: 5px;
  font-size: 17px;
}

.loading-box span {
  color: #555;
  font-size: 13px;
  line-height: 1.45;
}

.field-label {
  color: #333;
  font-size: 12px;
  font-weight: 700;
}

.number-input,
.select-input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  font: inherit;
  border-radius: 8px;
}

.profile-note,
.empty-material,
.status-line {
  color: #666;
  font-size: 12px;
  line-height: 1.45;
}

.profile-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  border-radius: 8px;
}

.profile-card:has(input:checked) {
  border-color: #73aaa4;
  background: #f2faf8;
  box-shadow: inset 4px 0 0 #3f8f88;
}

.profile-card input {
  margin-top: 3px;
}

.profile-card-body {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.profile-card-head {
  display: grid;
  gap: 2px;
}

.profile-card small,
.profile-card em {
  color: #666;
  font-size: 11.5px;
  font-style: normal;
  line-height: 1.35;
}

.profile-card em {
  color: var(--muted-strong);
}

.student-class-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.class-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 20px;
  padding: 2px 7px;
  border: 1px solid #d7c186;
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
}

.material-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.material-card img {
  width: 100%;
  max-height: 150px;
  object-fit: contain;
  border: 1px solid #e0d8ca;
  background: #f6f3ec;
}

.material-card textarea {
  width: 100%;
  resize: vertical;
  padding: 8px;
  border: 1px solid #c8c0b3;
  background: #fff;
  color: #222;
  font: 12.5px/1.45 Arial, "Microsoft YaHei", sans-serif;
}

.icon-text-button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid #c8c0b3;
  background: #fff;
  color: #333;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.preview-placeholder {
  min-height: 420px;
  display: grid;
  align-content: start;
  gap: 12px;
}

.paper-header {
  padding-bottom: 18px;
  border-bottom: 1px solid #222;
  margin-bottom: 24px;
}

.paper-header h2 {
  margin: 0 0 8px;
  font-size: 25px;
  line-height: 1.2;
}

.paper-header p {
  margin: 0 0 14px;
}

.student-line {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  font-size: 16px;
}

.question-list {
  display: grid;
  gap: 24px;
}

.question-block {
  break-inside: avoid;
  page-break-inside: avoid;
}

.question-meta {
  margin-bottom: 8px;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  font-size: 13px;
  font-weight: 700;
}

.stem {
  margin: 0 0 10px;
  font-size: 18px;
  line-height: 1.55;
}

.choices {
  margin: 8px 0 0 22px;
  padding: 0;
  font-size: 17px;
  line-height: 1.55;
}

.choices li {
  margin: 5px 0;
  padding-left: 4px;
}

.answer-lines span {
  display: block;
  height: 34px;
  border-bottom: 1px solid #222;
  margin: 8px 0;
}

.solution-block {
  margin-top: 12px;
  padding: 12px 14px;
  border-left: 3px solid #222;
  background: #faf9f5;
  font-size: 15.5px;
  line-height: 1.55;
}

.solution-block p {
  margin: 7px 0 0;
}

.teacher-analysis {
  margin-bottom: 26px;
}

.teacher-analysis h2 {
  margin: 0 0 12px;
  font-size: 22px;
}

.teacher-analysis dl {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
}

.teacher-analysis dl div {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 8px;
}

.teacher-analysis dt {
  font-weight: 700;
}

.teacher-analysis dd {
  margin: 0;
}

.source-analysis-card {
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: #fff;
}

.source-analysis-card h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.source-analysis-card p {
  margin: 6px 0;
}
