* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  background: #f6f7f9;
  color: #1f2937;
}

.shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 20px;
}

.brand {
  min-width: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3,
.ocr-workspace-title {
  color: #101828;
  font-weight: 700;
  overflow-wrap: anywhere;
}

h1 {
  font-size: 28px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

h2,
.ocr-workspace-title {
  font-size: 18px;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

h2 {
  margin-bottom: 16px;
}

h3 {
  color: #344054;
  font-size: 15px;
  line-height: 1.4;
  margin-bottom: 12px;
}

.topbar p {
  margin-top: 6px;
  color: #667085;
}

.grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
}

.panel {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 18px;
}

.wide {
  grid-column: 1 / -1;
}

label,
.user-box {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #475467;
}

.user-box {
  grid-template-columns: 1fr 140px;
  gap: 8px;
}

.auth-panel {
  width: min(420px, 100%);
}

.auth-card {
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  background: #fcfcfd;
  padding: 12px;
  margin-bottom: 12px;
}

.auth-card-title {
  font-size: 13px;
  font-weight: 600;
  color: #344054;
  margin-bottom: 10px;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.current-user {
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
  margin-bottom: 12px;
}

.current-user-label {
  font-size: 12px;
  font-weight: 600;
  color: #475467;
  margin-bottom: 8px;
}

.current-user-name {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
}

.current-user-id {
  margin-top: 6px;
  font-size: 12px;
  color: #667085;
  word-break: break-all;
}

.current-user-actions {
  margin-top: 12px;
}

.role-info {
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #475467;
}

.role-info-label {
  font-weight: 600;
  color: #344054;
  margin-bottom: 6px;
}

.auth-status {
  min-height: 22px;
  font-size: 13px;
  color: #475467;
}

.auth-status.error {
  color: #b42318;
}

.auth-status.success {
  color: #027a48;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 10px;
  font: inherit;
  background: #ffffff;
}

.upload-file-control {
  position: relative;
  display: flex;
  min-width: 0;
  align-items: center;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
}

#file {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-file-button {
  flex: 0 0 auto;
  margin: 4px;
  border-radius: 6px;
  padding: 10px 14px;
  background: #2563eb;
  color: #ffffff;
  font-weight: 600;
  transition: background 160ms ease, color 160ms ease;
}

.upload-file-selection-summary {
  min-width: 0;
  padding: 0 10px 0 6px;
  overflow: hidden;
  color: #667085;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-file-control:hover .upload-file-button {
  background: #1d4ed8;
}

.upload-file-control:active .upload-file-button {
  background: #1e40af;
}

#uploadBtn:hover {
  background: #1d4ed8;
}

#uploadBtn:active {
  background: #1e40af;
}

#uploadBtn {
  width: 100%;
  margin-right: 0;
}

#file:focus-visible ~ .upload-file-button {
  outline: 3px solid rgba(37, 99, 235, 0.2);
  outline-offset: 2px;
}

.upload-panel {
  align-self: start;
}

.upload-hint {
  margin-top: -4px;
  line-height: 1.5;
}

.upload-secondary-settings {
  border: 1px solid #dbe4f0;
  border-radius: 6px;
  background: #f8fafc;
}

.upload-secondary-settings > summary {
  padding: 8px 10px;
  color: #475467;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.upload-secondary-settings[open] > summary {
  border-bottom: 1px solid #dbe4f0;
}

.upload-secondary-settings > label {
  display: block;
  padding: 10px 11px 12px;
}

.upload-queue {
  display: grid;
  gap: 10px;
  max-height: 610px;
  margin: 12px 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.upload-queue.empty {
  min-height: 90px;
  place-items: center;
  padding: 14px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
}

.upload-empty {
  color: #64748b;
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
}

.upload-page-card {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 10px;
  padding: 9px;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #ffffff;
}

.upload-page-card.uploading {
  border-color: #93c5fd;
  background: #f8fbff;
}

.upload-page-card.uploaded {
  border-color: #86efac;
}

.upload-page-card.error {
  border-color: #fda29b;
  background: #fffbfa;
}

.upload-page-preview {
  position: relative;
  display: grid;
  width: 78px;
  height: 96px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #d0d5dd;
  border-radius: 7px;
  background:
    linear-gradient(45deg, #f8fafc 25%, transparent 25%),
    linear-gradient(-45deg, #f8fafc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f8fafc 75%),
    linear-gradient(-45deg, transparent 75%, #f8fafc 75%),
    #ffffff;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  background-size: 12px 12px;
}

.upload-page-preview img {
  width: 68px;
  height: 76px;
  object-fit: contain;
  transform: rotate(var(--page-rotation, 0deg));
  transition: transform 160ms ease;
}

.upload-document-icon {
  display: grid;
  width: 54px;
  height: 62px;
  place-items: center;
  border: 1px solid #93b4e2;
  border-radius: 5px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 800;
}

.upload-page-number {
  position: absolute;
  right: 3px;
  bottom: 3px;
  padding: 2px 5px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
}

.upload-page-details {
  min-width: 0;
}

.upload-page-details > strong,
.upload-page-details > small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-page-details > strong {
  color: #1f2937;
  font-size: 13px;
}

.upload-page-details > small {
  margin: 4px 0 7px;
  color: #667085;
  font-size: 11px;
}

.upload-page-details label {
  margin-bottom: 6px;
}

.upload-page-details select {
  padding: 7px;
  font-size: 12px;
}

.upload-item-status {
  min-height: 18px;
  color: #64748b;
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.upload-item-status.uploading {
  color: #1d4ed8;
}

.upload-item-status.uploaded {
  color: #15803d;
}

.upload-item-status.error {
  color: #b42318;
}

.upload-page-controls {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.upload-page-controls button {
  min-width: 0;
  margin: 0;
  padding: 7px 4px;
  font-size: 11px;
}

.upload-page-controls [data-upload-action="retry"] {
  grid-column: 1 / -1;
}

.upload-progress {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.upload-progress > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #22c55e;
  transition: width 180ms ease;
}

.multi-upload-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 8px;
}

.multi-upload-actions button {
  margin: 0;
}

.multi-upload-actions #uploadBtn {
  width: 100%;
}

textarea {
  resize: vertical;
  line-height: 1.5;
  font-family: Consolas, "SFMono-Regular", monospace;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  margin: 4px 8px 4px 0;
  background: #2563eb;
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
}

button:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

.secondary-btn {
  background: #2563eb;
}

.secondary-btn:hover {
  background: #1d4ed8;
}

.secondary-btn:active {
  background: #1e40af;
}

.secondary-btn:disabled {
  background: #cbd5e1;
}

.ghost-btn {
  background: #e5e7eb;
  color: #111827;
}

.danger-btn {
  background: #b42318;
}

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

.learning-records-header {
  align-items: flex-end;
}

.section-header .field-hint {
  margin: 6px 0 0;
  line-height: 1.5;
}

.records-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 9px;
  background: #eef2f6;
}

.records-tab {
  margin: 0;
  padding: 8px 14px;
  border: 1px solid transparent;
  background: transparent;
  color: #475467;
}

.records-tab:hover,
.records-tab:focus-visible {
  background: #ffffff;
  color: #1d4ed8;
}

.records-tab.active {
  border-color: #d0d5dd;
  background: #ffffff;
  color: #1d4ed8;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.records-tab-panel {
  min-width: 0;
}

.material-list-filters {
  display: grid;
  grid-template-columns: minmax(240px, 1.5fr) repeat(2, minmax(170px, 0.75fr));
  gap: 10px;
}

.material-list-filters label {
  margin-bottom: 0;
}

.selected-material-stats {
  margin: 10px 0 16px;
  padding: 14px;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #f8fafc;
}

.selected-material-stats-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.material-stats-cards {
  margin-bottom: 0;
}

.material-stats-cards .card {
  background: #ffffff;
}

.material-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  max-height: 420px;
  overflow-y: auto;
  padding: 2px 6px 2px 2px;
}

.material-card {
  overflow: hidden;
  border: 1px solid #e5e7eb;
  border-radius: 7px;
  background: #ffffff;
}

.material-card:hover,
.material-card:focus-within {
  border-color: #60a5fa;
  background: #f8fbff;
}

.material-card.active {
  border-color: #2563eb;
  background: #eff6ff;
}

.material-grid .item {
  width: 100%;
  min-height: 104px;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #111827;
  text-align: left;
  font: inherit;
}

.material-grid .item:hover,
.material-grid .item:focus-visible {
  background: transparent;
}

.material-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 10px 8px;
}

.material-submit-btn,
.material-delete-btn {
  margin: 0;
  padding: 7px 14px;
}

.material-grid .workflow-badge {
  font-size: 11px;
}

.history-section-header {
  padding-top: 2px;
}

.history-controls-only {
  justify-content: flex-end;
  min-height: 40px;
}

.history-materials-section {
  margin: 4px 0 18px;
}

.history-material-filters {
  display: grid;
  grid-template-columns: minmax(240px, 1.5fr) minmax(170px, 0.75fr);
  gap: 10px;
}

.history-material-filters label {
  margin-bottom: 0;
}

.history-materials-section .history-materials-status {
  min-height: 24px;
  margin: 12px 0 8px;
  padding: 2px 0;
  line-height: 1.5;
  text-align: left;
  overflow-wrap: anywhere;
}

.history-material-grid {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  max-height: 360px;
  overflow-y: auto;
  padding: 2px 6px 2px 2px;
}

.history-material-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 9px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 7px;
  background: #ffffff;
}

.history-material-card:hover {
  border-color: #93c5fd;
}

.history-material-card.active {
  border-color: #2563eb;
  background: #eff6ff;
}

.history-material-select-btn {
  display: flex;
  width: 100%;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 9px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.history-material-select-btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 4px;
  border-radius: 4px;
}

.history-material-card strong {
  overflow-wrap: anywhere;
}

.history-material-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  color: #667085;
  font-size: 12px;
}

.history-material-select-hint {
  color: #2563eb;
  font-size: 12px;
  font-weight: 700;
}

.history-material-open-btn {
  align-self: flex-end;
  margin: auto 0 0;
}

.workflow-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 7px 0 5px;
}

.workflow-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  background: #f1f5f9;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
}

.workflow-badge.processing {
  background: #dbeafe;
  color: #1d4ed8;
}

.workflow-badge.review_required {
  background: #fef3c7;
  color: #92400e;
}

.workflow-badge.completed {
  background: #dcfce7;
  color: #166534;
}

.workflow-badge.failed {
  background: #fee2e2;
  color: #b91c1c;
}

.workflow-error {
  flex-basis: 100%;
  color: #b42318;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.notice {
  min-height: 22px;
  margin: 8px 0;
  color: #92400e;
  font-size: 13px;
}

.notice.success {
  color: #067647;
}

.analysis-guidance {
  min-height: 0;
  margin: -4px 0 8px;
  color: #667085;
  font-size: 12px;
  line-height: 1.5;
}

.analysis-guidance:empty {
  display: none;
}

.field-hint {
  margin: -6px 0 12px;
  color: #667085;
  font-size: 12px;
}

.field-hint.upload-queue-hint {
  margin: 8px 0 10px;
  line-height: 1.5;
}

.ocr-workspace-details > summary,
.ocr-section > summary,
.ocr-question > summary {
  cursor: pointer;
  user-select: none;
}

.ocr-workspace-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  list-style: none;
  border: 1px solid #dbe3ef;
  border-radius: 9px;
  background: #f8fafc;
  color: #111827;
  font-size: 18px;
  font-weight: 700;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.ocr-workspace-summary::-webkit-details-marker {
  display: none;
}

.ocr-workspace-summary:hover {
  border-color: #9ebee8;
  background: #f1f7ff;
}

.ocr-workspace-summary:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}

.ocr-workspace-details[open] > .ocr-workspace-summary {
  border-color: #b8cbe6;
  background: #eef5ff;
}

.ocr-workspace-title {
  flex: 1 1 auto;
  min-width: 0;
}

.ocr-workspace-summary-right {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.ocr-workspace-summary-meta {
  min-width: 0;
  color: #667085;
  font-size: 12px;
  font-weight: 500;
  text-align: right;
}

.ocr-workspace-toggle-label,
.ocr-section > summary::after {
  display: inline-flex;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid #93b4e2;
  border-radius: 999px;
  background: #ffffff;
  color: #24589c;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

.ocr-section > summary::after {
  content: "›";
  font-size: 20px;
  transition: transform 160ms ease;
}

.ocr-toggle-icon {
  display: inline-block;
  font-size: 20px;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 160ms ease;
}

.ocr-workspace-details[open] .ocr-toggle-icon,
.analysis-report-details[open] .ocr-toggle-icon {
  transform: rotate(90deg);
}

.ocr-workspace-content {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.analysis-report-content {
  margin-top: 14px;
}

.workspace-clear-actions {
  display: grid;
  margin-top: 22px;
  padding: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #e2e8f0;
}

.workspace-clear-actions button {
  margin: 0;
  width: 100%;
}

.workspace-clear-btn,
.workspace-clear-btn:hover,
.workspace-clear-btn:active {
  border: 1px solid #475569;
  background: #475569;
  color: #ffffff;
}

.workspace-clear-btn:hover {
  border-color: #334155;
  background: #334155;
}

.workspace-clear-btn:active {
  border-color: #1e293b;
  background: #1e293b;
}

.workspace-clear-btn:disabled {
  border-color: #94a3b8;
  background: #94a3b8;
  color: #f8fafc;
}

.analysis-report-summary,
.analysis-report-summary:hover,
.analysis-report-details[open] > .analysis-report-summary {
  padding: 0;
  border-color: transparent;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.ocr-section {
  overflow: hidden;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #f8fafc;
}

.ocr-section > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  list-style: none;
  color: #344054;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
}

.ocr-section > summary::-webkit-details-marker {
  display: none;
}

.ocr-section[open] > summary {
  border-bottom: 1px solid #dbe3ef;
  background: #f1f5f9;
}

.ocr-section[open] > summary::after {
  transform: rotate(90deg);
}

.ocr-section-content {
  padding: 12px;
}

.ocr-section-content > :last-child {
  margin-bottom: 0;
}

.ocr-analysis-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ocr-analysis-actions .notice {
  flex: 1;
  margin: 0;
}

.ocr-text-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.ocr-questions {
  display: grid;
  gap: 10px;
}

.ocr-question {
  overflow: hidden;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #ffffff;
}

.ocr-question-number {
  padding: 10px;
  color: #344054;
  font-weight: 700;
}

.ocr-question[open] .ocr-question-number {
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
}

.ocr-question-text {
  padding: 10px;
  color: #111827;
}

.ocr-question-image-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 10px 10px;
}

.ocr-question-thumbnail {
  width: 140px;
  max-height: 100px;
  object-fit: contain;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  background: #ffffff;
}

.question-image-editor {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #84adff;
  border-radius: 8px;
  background: #f5f8ff;
}

.question-image-editor-header,
.question-image-page-controls,
.question-image-editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.question-image-canvas {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 10px;
  line-height: 0;
  touch-action: none;
  cursor: crosshair;
}

.question-image-canvas img {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.question-image-selection,
.saved-question-region {
  position: absolute;
  border: 2px solid #2563eb;
  background: rgb(37 99 235 / 12%);
  pointer-events: none;
}

.saved-question-region::after {
  content: attr(data-label);
  position: absolute;
  top: 2px;
  left: 2px;
  padding: 1px 5px;
  border-radius: 999px;
  background: #2563eb;
  color: #ffffff;
  font-size: 11px;
  line-height: 1.4;
}

.knowledge-browser {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(260px, 1.1fr);
  gap: 12px;
  margin: 12px 0;
}

.knowledge-tree,
.knowledge-preview,
.metadata-editor {
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  background: #ffffff;
  padding: 10px;
}

.knowledge-tree {
  max-height: 280px;
  overflow: auto;
}

.tree-node {
  display: block;
  width: 100%;
  margin: 0 0 6px;
  padding: 7px 8px;
  background: transparent;
  color: #111827;
  text-align: left;
  border: 1px solid transparent;
  font-weight: 500;
}

.tree-node.child {
  width: calc(100% - 16px);
  margin-left: 16px;
  color: #334155;
}

.tree-node:hover,
.tree-node.active {
  border-color: #93c5fd;
  background: #eff6ff;
}

.knowledge-preview {
  min-height: 120px;
  color: #475467;
}

.knowledge-preview strong {
  display: block;
  margin-bottom: 8px;
  color: #111827;
}

.knowledge-preview p {
  margin: 6px 0;
}

.knowledge-preview span {
  color: #344054;
  font-weight: 700;
}

.metadata-editor {
  margin: 10px 0;
}

.metadata-editor summary {
  margin-bottom: 8px;
  cursor: pointer;
  color: #344054;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
}

.answer-candidate-panel {
  scroll-margin-top: 18px;
}

.answer-candidate-disclosure-summary,
.answer-candidate-disclosure-summary:hover,
.answer-candidate-details[open] > .answer-candidate-disclosure-summary {
  padding: 0;
  border-color: transparent;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.answer-candidate-content {
  margin-top: 16px;
}

.answer-attempt-select {
  max-width: 320px;
}

.answer-attempt-upload {
  display: grid;
  gap: 12px;
  margin: 14px 0;
  padding: 14px;
  border: 1px solid #bfdbfe;
  border-radius: 9px;
  background: #f8fbff;
}

.answer-attempt-upload-header,
.answer-attempt-upload-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.answer-attempt-upload-queue {
  display: grid;
  gap: 8px;
}

.answer-attempt-upload-queue.empty {
  padding: 14px;
  border: 1px dashed #cbd5e1;
  border-radius: 7px;
  color: #64748b;
  text-align: center;
}

.answer-attempt-upload-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 150px auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid #dbe3ef;
  border-radius: 7px;
  background: #ffffff;
}

.answer-attempt-upload-preview {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #dbe3ef;
  border-radius: 5px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 700;
}

.answer-attempt-upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.answer-attempt-item-actions {
  display: flex;
  gap: 6px;
}

.answer-attempt-upload-item strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.answer-candidate-header {
  align-items: flex-end;
}

.answer-candidate-header .field-hint {
  margin: 5px 0 0;
}

.answer-candidate-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.answer-candidate-actions button {
  margin: 0;
}

.material-file-gallery {
  display: flex;
  gap: 10px;
  margin: 12px 0 16px;
  padding: 10px;
  overflow-x: auto;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #f8fafc;
}

.material-file-gallery-item {
  display: grid;
  flex: 0 0 104px;
  gap: 6px;
  min-width: 0;
}

.material-file-gallery-item img,
.material-file-placeholder {
  display: grid;
  width: 104px;
  height: 82px;
  place-items: center;
  object-fit: contain;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 800;
}

.material-file-gallery-item > span:last-child {
  overflow: hidden;
  color: #475569;
  font-size: 11px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.answer-candidate-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
}

.answer-candidate-summary strong {
  margin-right: auto;
  color: #1e3a8a;
}

.answer-candidate-summary span {
  padding: 3px 7px;
  border-radius: 999px;
  background: #ffffff;
  color: #475569;
  font-size: 11px;
}

.answer-candidates {
  display: grid;
  gap: 12px;
}

.answer-candidates.empty {
  min-height: 90px;
  place-items: center;
  padding: 18px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #64748b;
  font-size: 13px;
  text-align: center;
}

.answer-candidate-card {
  padding: 14px;
  border: 1px solid #dbe3ef;
  border-radius: 9px;
  background: #ffffff;
}

.answer-candidate-card.confirmed {
  border-color: #bbf7d0;
  background: #fbfffc;
}

.answer-candidate-card.unmatched {
  border-color: #fbbf24;
  background: #fffbeb;
}

.answer-candidate-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.answer-candidate-heading > div {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.candidate-confidence {
  padding: 3px 7px;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  font-size: 11px;
  font-weight: 700;
}

.candidate-confidence.low {
  background: #fef3c7;
  color: #92400e;
}

.candidate-answer-details {
  display: grid;
  justify-items: start;
  gap: 8px;
}

.answer-candidate-body {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.85fr);
  gap: 16px;
}

.answer-candidate-evidence {
  min-width: 0;
}

.answer-candidate-evidence > img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
}

.candidate-no-evidence {
  display: grid;
  gap: 8px;
  min-height: 120px;
  place-items: center;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #94a3b8;
  font-size: 12px;
}

.candidate-no-evidence button {
  margin: 0;
}

.answer-candidate-evidence p {
  margin-top: 9px;
  color: #334155;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.answer-candidate-evidence p strong {
  display: block;
  margin-bottom: 2px;
  color: #64748b;
  font-size: 11px;
}

.candidate-question {
  min-width: 0;
  margin-top: 12px;
  color: #111827;
  font-size: 15px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.candidate-question > strong {
  display: block;
  margin-bottom: 5px;
  color: #334155;
  font-size: 14px;
  font-weight: 700;
}

.candidate-question-text p {
  margin: 0;
  white-space: normal;
}

.answer-candidate-editor {
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}

.toggle-recognized-answer {
  width: 100%;
  margin: 0 0 12px;
}

.candidate-answer-text {
  margin: -4px 0 12px;
  padding: 10px;
  border: 1px solid #bfdbfe;
  border-radius: 7px;
  background: #ffffff;
  color: #1e293b;
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.candidate-answer-text p {
  margin: 0;
}

.answer-candidate-editor label:last-of-type {
  margin-bottom: 0;
}

.candidate-score-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.candidate-warning {
  margin-top: 10px;
  padding: 8px 10px;
  border-left: 3px solid #f59e0b;
  background: #ffffff;
  color: #92400e;
  font-size: 12px;
}

.report-answer-confirmation {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 8px;
  color: #475569;
  font-size: 12px;
}

.answer-candidate-confirm-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.answer-evidence-editor {
  margin: 16px 0;
  padding: 14px;
  border: 1px solid #60a5fa;
  border-radius: 10px;
  background: #eff6ff;
  scroll-margin-top: 18px;
}

.answer-evidence-source-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 10px;
}

.answer-evidence-source-controls label {
  margin: 0;
}

.answer-evidence-region-list {
  display: grid;
  gap: 7px;
  margin: 10px 0;
}

.answer-evidence-region-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid #bfdbfe;
  border-radius: 7px;
  background: #ffffff;
  cursor: grab;
}

.answer-evidence-region-item > div {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.answer-evidence-region-item button {
  margin: 0;
  padding: 5px 8px;
  font-size: 11px;
}

.adjust-answer-evidence {
  margin-top: 9px;
}

.report-answer-evidence {
  display: grid;
  gap: 8px;
  margin: 12px 0;
  padding: 10px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #f8fbff;
}

.report-answer-evidence > strong {
  color: #1e3a8a;
  font-size: 13px;
}

.report-answer-evidence > img {
  display: block;
  width: min(100%, 720px);
  max-height: 420px;
  object-fit: contain;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #ffffff;
}

.report-answer-evidence > p {
  margin: 0;
  color: #334155;
  white-space: pre-wrap;
}

.answer-candidate-confirm-row button {
  margin: 0;
}

.answer-candidate-confirm-row .field-hint {
  margin: 0;
}

.hidden {
  display: none;
}

.preview-wrap {
  position: relative;
  width: 100%;
  max-height: 360px;
  overflow: hidden;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  margin: 10px 0;
  background: #f8fafc;
  user-select: none;
  touch-action: none;
  cursor: crosshair;
}

.preview-wrap img {
  width: 100%;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.selection-box {
  position: absolute;
  border: 2px solid #2563eb;
  background: rgba(37, 99, 235, 0.12);
  pointer-events: none;
}

.item {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 10px;
  cursor: pointer;
}

.item.active {
  border-color: #2563eb;
  background: #eff6ff;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px;
  background: #fafafa;
}

.card strong {
  display: block;
  font-size: 22px;
  margin-top: 6px;
}

.questions {
  display: grid;
  gap: 12px;
}

.question {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px;
}

.analysis-failed-question {
  border-color: #fda29b;
  background: #fffbfa;
}

.analysis-failed-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.analysis-failed-error {
  margin: 10px 0;
  padding: 9px 11px;
  border-radius: 6px;
  background: #fef3f2;
  color: #b42318;
  font-size: 13px;
}

.report-question-thumbnail {
  display: block;
  max-width: min(100%, 520px);
  max-height: 320px;
  margin: 10px 0;
  object-fit: contain;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  background: #ffffff;
}

.preview-panel {
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  background: #fcfcfd;
  overflow: hidden;
  margin-bottom: 12px;
}

.preview-header {
  padding: 10px 12px;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
  font-size: 13px;
  font-weight: 600;
  color: #475467;
}

.ocr-preview {
  min-height: 180px;
  padding: 14px;
  line-height: 1.65;
  overflow-x: auto;
}

.ocr-preview.empty {
  color: #98a2b3;
}

.math-render-warning {
  margin: 0 0 10px;
  padding: 8px 10px;
  border: 1px solid #f3b7b2;
  border-radius: 8px;
  color: #b42318;
  background: #fff4f2;
  font-size: 14px;
  font-weight: 600;
}

.math-markdown {
  min-width: 0;
  overflow-x: auto;
}

.math-markdown table {
  width: auto;
  max-width: 100%;
  margin: 12px 0;
  border: 1px solid #667085;
  border-collapse: collapse;
  border-spacing: 0;
  color: inherit;
  font-size: 0.95em;
}

.math-markdown th,
.math-markdown td {
  padding: 7px 12px;
  border: 1px solid #667085;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

.math-markdown th {
  background: #f8fafc;
  font-weight: 700;
}

.math-markdown table .katex {
  font-size: 1em;
}

.ocr-preview p,
.ocr-preview ul,
.ocr-preview ol,
.ocr-preview pre,
.ocr-preview blockquote {
  margin: 0 0 12px;
}

.ocr-preview p:last-child,
.ocr-preview ul:last-child,
.ocr-preview ol:last-child,
.ocr-preview pre:last-child,
.ocr-preview blockquote:last-child {
  margin-bottom: 0;
}

.ocr-preview code {
  font-family: Consolas, "SFMono-Regular", monospace;
  background: #eef2ff;
  padding: 2px 4px;
  border-radius: 4px;
}

.ocr-preview pre {
  background: #111827;
  color: #f9fafb;
  padding: 12px;
  border-radius: 8px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.tag {
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  padding: 4px 8px;
  font-size: 12px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-header h2,
.section-header h3,
.selected-material-stats-header h3,
.ocr-review-heading h3 {
  margin-bottom: 0;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.teacher-query-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.teacher-task-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0 18px;
}

.teacher-task-summary article {
  display: grid;
  gap: 5px;
  padding: 12px 14px;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #f8fafc;
  color: #475467;
}

.teacher-task-summary strong {
  color: #1d2939;
}

.teacher-student-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.teacher-student-row label,
.teacher-workspace-actions label {
  margin-bottom: 0;
}

.teacher-workspace-actions {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.teacher-workspace-actions button {
  min-height: 39px;
  margin: 0;
  white-space: nowrap;
}

.teacher-confirm-control {
  display: grid;
  gap: 6px;
  min-width: 142px;
  color: #475467;
  font-size: 13px;
}

.teacher-confirm-control button {
  min-height: 39px;
  margin: 0;
  white-space: nowrap;
}

.teacher-header-actions {
  display: grid;
  gap: 8px;
  width: 132px;
}

.teacher-header-actions button {
  width: 100%;
  min-height: 38px;
  margin: 0;
  white-space: nowrap;
}

.teacher-workbench {
  border-color: #bfdbfe;
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 42%);
}

.teacher-workbench-header { align-items: flex-start; }

.teacher-mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 5px;
  border-radius: 10px;
  background: #eef2f7;
}

.teacher-mode-tab {
  margin: 0;
  border: 1px solid transparent;
  background: transparent;
  color: #475569;
}

.teacher-mode-tab.active {
  border-color: #bfdbfe;
  background: #ffffff;
  color: #1d4ed8;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

.teacher-mode-intro {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  padding: 12px 14px;
  border-left: 4px solid #2563eb;
  border-radius: 6px;
  background: #eff6ff;
  color: #334155;
}

.teacher-mode-intro.hidden,
.teacher-guidance-controls.hidden { display: none; }

.teacher-guidance-controls {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(300px, 1.2fr) auto;
  gap: 10px;
  align-items: end;
  margin: 14px 0 10px;
}

.teacher-guidance-controls label { margin: 0; }

.teacher-guidance-controls button {
  min-height: 39px;
  margin: 0;
  white-space: nowrap;
}

.teacher-task-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 8px;
}

.teacher-task-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  margin: 0;
  padding: 13px 14px;
  border: 1px solid #dbe3ef;
  background: #ffffff;
  color: #334155;
  text-align: left;
}

.teacher-task-card strong {
  grid-row: 1 / 3;
  grid-column: 2;
  align-self: center;
  color: #1d4ed8;
  font-size: 28px;
}

.teacher-task-card small { color: #64748b; }

.teacher-task-card.pending {
  border-color: #fbbf24;
  background: #fffbeb;
}

.teacher-task-card.complete strong { color: #15803d; }

.question-bank-panel {
  display: grid;
  gap: 16px;
}

.question-bank-panel.hidden,
.question-bank-publisher.hidden { display: none; }

.question-bank-publisher {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #f8fbff;
}

.question-bank-publish-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.7fr);
  gap: 18px;
  align-items: end;
}

.question-bank-publish-heading h3,
.question-bank-set-card h3 { margin: 0; }

.question-bank-publish-heading label { margin: 0; }

.question-bank-publish-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.question-bank-publish-actions button { margin: 0; }

.question-bank-publish-questions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.question-bank-publish-questions.empty {
  display: block;
  padding: 14px;
  color: #64748b;
}

.question-bank-publish-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 9px;
  margin: 0;
  padding: 10px;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #ffffff;
}

.question-bank-publish-option input {
  width: auto;
  margin-top: 3px;
}

.question-bank-publish-option small {
  grid-column: 2;
  color: #64748b;
}

.question-bank-publish-option.disabled {
  background: #f8fafc;
  opacity: 0.65;
}

.question-bank-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 10px;
}

.question-bank-filters label { margin: 0; }

.question-bank-sets,
.question-bank-items {
  display: grid;
  gap: 12px;
}

.question-bank-sets.empty {
  padding: 24px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: #64748b;
  text-align: center;
}

.question-bank-set-card {
  padding: 16px;
  border: 1px solid #dbe3ef;
  border-radius: 10px;
  background: #ffffff;
}

.question-bank-set-card > header,
.question-bank-item-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.question-bank-set-card > header p {
  margin: 4px 0 0;
  color: #64748b;
}

.question-bank-status {
  display: inline-flex;
  margin-bottom: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  font-size: 12px;
  font-weight: 700;
}

.question-bank-status.archived {
  background: #e2e8f0;
  color: #475569;
}

.question-bank-items {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.question-bank-item {
  min-width: 0;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}

.question-bank-item img {
  display: block;
  width: 100%;
  max-height: 280px;
  margin: 8px 0;
  object-fit: contain;
  border: 1px solid #dbe3ef;
  border-radius: 6px;
  background: #ffffff;
}

.question-bank-item-text { overflow-wrap: anywhere; }

.teacher-selected-material {
  color: #334155;
  font-size: 14px;
  font-weight: 600;
}

.teacher-assessment-view {
  margin: 14px 0;
  padding: 12px 14px;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #f8fafc;
}

.teacher-assessment-view summary {
  cursor: pointer;
  color: #344054;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
}

.ocr-review-workspace > details > summary {
  cursor: pointer;
  color: #344054;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
}

.teacher-assessment-view .field-hint {
  margin: 10px 0;
}

.assessment-answer-list {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(240px, 1.3fr);
  margin: 0;
  border-top: 1px solid #e2e8f0;
}

.assessment-answer-list dt,
.assessment-answer-list dd {
  margin: 0;
  padding: 8px 6px;
  border-bottom: 1px solid #e2e8f0;
}

.assessment-answer-list dt {
  color: #64748b;
  font-size: 12px;
}

.assessment-answer-list dd {
  color: #1f2937;
  overflow-wrap: anywhere;
}

.assessment-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 4px 14px;
}

.assessment-notes,
.assessment-submit-row {
  grid-column: 1 / -1;
}

.assessment-submit-row,
.assessment-header-actions,
.history-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.assessment-submit-row .field-hint {
  margin: 0;
}

.assessment-header-actions button {
  margin: 0;
  white-space: nowrap;
}

.history-header-actions button {
  margin: 0;
  white-space: nowrap;
}

.history-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
}

.analytics-subsection-header {
  margin: 20px 0 10px;
}

.analytics-subsection-header h4,
.analytics-subsection-header p {
  margin: 0;
}

.analytics-subsection-header p {
  margin-top: 4px;
}

.analytics-advanced-filters {
  margin: 12px 0 4px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}

.analytics-advanced-filters summary {
  cursor: pointer;
  color: #475467;
  font-weight: 700;
}

.analytics-advanced-filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.history-table td:last-child {
  font-weight: 700;
  color: #1d4ed8;
}

.ocr-review-workspace {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #f8fafc;
}

.ocr-review-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.ocr-review-primary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.teacher-ocr-review-summary,
.teacher-ocr-review-summary:hover,
.ocr-review-workspace[open] > .teacher-ocr-review-summary {
  padding: 0;
  border-color: transparent;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.teacher-ocr-review-title-group {
  display: grid;
  flex: 1 1 auto;
  min-width: 0;
  gap: 6px;
}

.teacher-ocr-review-title-group .ocr-workspace-summary-meta {
  text-align: left;
}

.teacher-ocr-review-content {
  margin-top: 16px;
}

.ocr-review-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 14px 0;
}

.teacher-ocr-preview {
  margin-top: 14px;
}

.teacher-ocr-preview-heading,
.teacher-ocr-preview-controls,
.teacher-ocr-zoom-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.teacher-ocr-preview-heading {
  justify-content: space-between;
  margin-bottom: 8px;
}

.teacher-ocr-preview-toolbar {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.teacher-ocr-preview-controls,
.teacher-ocr-zoom-controls {
  justify-content: flex-end;
}

.teacher-ocr-preview-controls .secondary-btn,
.teacher-ocr-zoom-controls .secondary-btn {
  width: auto;
  min-width: 72px;
  padding: 7px 12px;
}

.teacher-ocr-preview-page-meta {
  max-width: min(420px, 45vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.teacher-ocr-zoom-controls {
  color: #475467;
  font-size: 13px;
  font-weight: 700;
}

#teacherOcrZoomLabel {
  width: 46px;
  text-align: center;
}

.teacher-ocr-preview-frame {
  display: block;
  min-height: 280px;
  max-height: 560px;
  overflow: auto;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #e2e8f0;
  scroll-behavior: smooth;
}

.teacher-ocr-preview-frame:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.24);
  outline-offset: 2px;
}

.teacher-ocr-preview-frame img {
  display: block;
  width: auto;
  height: auto;
  margin: 0 auto;
  max-width: none;
  max-height: none;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-drag: none;
}

.teacher-ocr-preview-frame img.hidden {
  display: none;
}

.teacher-ocr-preview-frame > .field-hint:not(.hidden) {
  display: grid;
  min-height: 278px;
  place-items: center;
  padding: 16px;
  text-align: center;
}

.analysis-report-loading {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 700;
}

.analysis-report-loading.hidden {
  display: none;
}

.loading-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #bfdbfe;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: report-loading-spin 700ms linear infinite;
}

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

.report-loading-placeholder,
.report-load-error {
  padding: 24px;
  border: 1px dashed #bfdbfe;
  border-radius: 8px;
  background: #f8fbff;
  color: #475467;
  text-align: center;
}

.report-load-error {
  border-color: #fecaca;
  background: #fff7f7;
  color: #b42318;
}

.ocr-review-text-field {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.ocr-review-text-field > span {
  font-weight: 700;
}

.ocr-review-text {
  width: 100%;
  height: 340px;
  min-height: 252px;
  max-height: 560px;
  margin: 8px 0 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #334155;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
}

.ocr-review-text[readonly] {
  cursor: default;
}

.teacher-ocr-effect-preview {
  margin: 16px 0;
  overflow: hidden;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #ffffff;
}

.teacher-ocr-effect-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid #dbeafe;
  background: #eff6ff;
}

.ocr-rendered-preview {
  min-height: 180px;
  max-height: 460px;
  padding: 16px;
  overflow: auto;
  color: #172033;
  font-size: 15px;
  line-height: 1.65;
}

.ocr-rendered-preview.empty {
  display: grid;
  place-items: center;
  color: #64748b;
}

.teacher-ocr-diff-details {
  margin: 14px 0;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #ffffff;
}

.teacher-ocr-diff-details > summary {
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 700;
}

.ocr-diff-legend {
  display: flex;
  gap: 12px;
  padding: 0 12px 8px;
  color: #64748b;
  font-size: 12px;
}

.ocr-diff-legend span::before {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  border-radius: 2px;
  content: "";
}

.ocr-diff-legend .removed::before {
  background: #fee2e2;
}

.ocr-diff-legend .added::before {
  background: #dcfce7;
}

.ocr-diff-view {
  max-height: 360px;
  margin: 0 12px 12px;
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
  line-height: 1.5;
}

.ocr-diff-line {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  min-height: 24px;
  padding: 2px 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ocr-diff-line.added {
  background: #ecfdf3;
  color: #166534;
}

.ocr-diff-line.removed {
  background: #fef2f2;
  color: #991b1b;
}

.ocr-diff-line.unchanged {
  color: #64748b;
}

.teacher-ocr-reparse-hint {
  margin: 8px 0 0;
}

.revision-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.revision-item {
  padding: 10px 12px;
  border-left: 3px solid #94a3b8;
  border-radius: 4px;
  background: #ffffff;
}

.revision-item strong,
.revision-item small {
  display: block;
}

.revision-item small {
  margin-top: 4px;
  color: #64748b;
}

.revision-preview {
  margin-top: 6px;
  color: #334155;
  font-size: 12px;
  white-space: pre-wrap;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
  background: #ffffff;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

.data-table th {
  background: #f8fafc;
  color: #475467;
  font-weight: 600;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.row-actions button {
  margin: 0;
  padding: 7px 9px;
  white-space: nowrap;
}

.review-editor {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  background: #f8fafc;
}

.review-editor select,
.review-editor input,
.review-editor textarea {
  width: 100%;
}

.student-suggestion-review {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #f8fbff;
}

.suggestion-current,
.pending-suggestion {
  margin: 10px 0;
  padding: 9px 10px;
  border-radius: 6px;
  background: #ffffff;
}

.pending-suggestion {
  border-left: 3px solid #f59e0b;
}

.student-knowledge-actions,
.student-inline-review-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0;
}

.student-knowledge-actions button,
.student-inline-review-actions button {
  margin: 0;
  padding: 6px 10px;
}

.student-analysis-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0 4px;
  padding-top: 10px;
  border-top: 1px solid #dbe3ef;
}

.student-analysis-actions button {
  margin: 0;
  padding: 6px 10px;
}

.student-analysis-actions span {
  color: #52657f;
  font-size: 13px;
}

.single-question-analysis-status {
  min-height: 0;
  margin-bottom: 8px;
  font-size: 13px;
}

.single-question-analysis-status.success {
  color: #166534;
}

.single-question-analysis-status.error {
  color: #b42318;
}

.student-inline-knowledge-editor {
  margin: 8px 0 10px;
  padding: 10px 0 0;
  border-top: 1px solid #dbe3ef;
}

.student-inline-knowledge-editor .review-classification {
  margin: 0 0 8px;
  padding: 0;
}

.student-suggestion-pending-inline {
  margin: 8px 0;
  padding: 8px 10px;
  border-left: 3px solid #f59e0b;
  background: #fffbeb;
  font-size: 13px;
}

.suggestion-catalog-error {
  margin-bottom: 8px;
  color: #b42318;
}

.suggestion-history {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.suggestion-history-item {
  padding: 9px 10px;
  border-left: 3px solid #94a3b8;
  border-radius: 4px;
  background: #ffffff;
  font-size: 13px;
}

.suggestion-history-item > span {
  margin-left: 8px;
  color: #64748b;
  font-size: 11px;
}

.suggestion-review-comment {
  margin-top: 5px;
  color: #475569;
}

.suggestion-review-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.suggestion-review-actions button {
  margin: 0;
}

.review-summary {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 3px solid #2563eb;
  border-radius: 4px;
  background: #eff6ff;
  color: #344054;
}

.review-summary > span {
  color: #667085;
  font-size: 12px;
}

.teacher-annotation-panel {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #f8fbff;
}

.teacher-annotation-panel.locked {
  border-color: #d0d5dd;
  background: #f8fafc;
  color: #667085;
}

.teacher-annotation-panel.readonly {
  border-color: #c7d7fe;
}

.teacher-annotation-panel p,
.teacher-annotation-revision p {
  margin: 0;
  white-space: pre-wrap;
}

.teacher-annotation-heading,
.teacher-annotation-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.teacher-annotation-heading span,
.teacher-annotation-heading small,
.teacher-annotation-actions small {
  color: #667085;
  font-size: 12px;
}

.teacher-annotation-input {
  margin: 0;
  resize: vertical;
}

.teacher-annotation-actions button {
  margin: 0;
}

.teacher-annotation-status {
  min-height: 20px;
  font-size: 13px;
}

.teacher-annotation-history {
  border-top: 1px solid #dbe3ef;
  padding-top: 8px;
}

.teacher-annotation-history summary {
  cursor: pointer;
  color: #1d4ed8;
  font-weight: 700;
}

.teacher-annotation-history-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.teacher-annotation-revision {
  display: grid;
  gap: 4px;
  padding: 9px 10px;
  border-radius: 6px;
  background: #ffffff;
}

.teacher-annotation-revision small {
  color: #667085;
}

.review-classification {
  margin: 12px 0;
  padding: 10px;
  border-radius: 6px;
  background: #ffffff;
}

.review-classification > strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

.review-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #f8fafc;
}

.review-progress.hidden {
  display: none;
}

.review-filter-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.review-filter-actions button {
  margin: 0;
  padding: 6px 12px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
}

.review-filter-actions button.active {
  border-color: #2563eb;
  background: #2563eb;
  color: #ffffff;
}

.question-heading {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
}

.review-status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}

.review-status-badge.reviewed {
  background: #dcfce7;
  color: #166534;
}

.review-status-badge.unreviewed {
  background: #ffedd5;
  color: #9a3412;
}

.review-filter-empty {
  padding: 24px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: #64748b;
  text-align: center;
  background: #f8fafc;
}

.muted-tag {
  background: #f2f4f7;
  color: #475467;
}

.selected-knowledge-points {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
  margin: 6px 0 10px;
}

.selected-knowledge-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px 5px 10px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1e3a8a;
  font-size: 13px;
}

.selected-knowledge-tag button {
  margin: 0;
  padding: 0 3px;
  border: 0;
  background: transparent;
  color: #1e3a8a;
  font-size: 18px;
  line-height: 1;
}

.knowledge-add-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr) auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 12px;
}

.knowledge-add-row button {
  margin: 0;
}

.review-fields {
  display: grid;
  grid-template-columns: minmax(140px, 0.4fr) minmax(220px, 1fr);
  gap: 12px;
}

.analysis-save-status,
.record-save-status,
.suggestion-feedback,
.teacher-annotation-status {
  min-height: 20px;
  margin-top: 8px;
  font-size: 13px;
}

.analysis-save-status.pending,
.record-save-status.pending,
.suggestion-feedback.pending,
.teacher-annotation-status.pending {
  color: #92400e;
}

.analysis-save-status.success,
.record-save-status.success,
.suggestion-feedback.success,
.teacher-annotation-status.success {
  color: #067647;
}

.analysis-save-status.error,
.record-save-status.error,
.suggestion-feedback.error,
.teacher-annotation-status.error {
  color: #b42318;
}

@media (max-width: 820px) {
  .topbar,
  .grid {
    display: block;
  }

  .panel {
    margin-bottom: 16px;
  }

  .section-header,
  .selected-material-stats-header {
    align-items: stretch;
    flex-direction: column;
  }

  .answer-candidate-actions {
    justify-content: stretch;
  }

  .answer-candidate-actions button {
    flex: 1 1 180px;
  }

  .answer-attempt-upload-item {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .answer-attempt-upload-item > select,
  .answer-attempt-item-actions {
    grid-column: 1 / -1;
  }

  .answer-attempt-item-actions button {
    flex: 1 1 auto;
  }

  .answer-evidence-source-controls {
    grid-template-columns: 1fr;
  }

  .answer-evidence-region-item {
    align-items: stretch;
    flex-direction: column;
  }

  .teacher-header-actions {
    width: 100%;
  }

  .ocr-workspace-summary {
    align-items: stretch;
    flex-direction: column;
  }

  .ocr-workspace-summary-right {
    width: 100%;
    justify-content: space-between;
  }

  .ocr-workspace-summary-meta {
    text-align: left;
  }

  .ocr-analysis-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .learning-records-header {
    align-items: stretch;
    flex-direction: column;
  }

  .records-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .user-box,
  .admin-layout,
  .knowledge-browser,
  .filters,
  .material-list-filters,
  .history-material-filters,
  .teacher-student-row,
  .teacher-workspace-actions,
  .teacher-task-summary,
  .teacher-guidance-controls,
  .teacher-task-cards,
  .question-bank-publish-heading,
  .question-bank-publish-questions,
  .question-bank-filters,
  .question-bank-items,
  .knowledge-add-row,
  .review-fields,
  .history-filters,
  .analytics-advanced-filter-grid,
  .assessment-form,
  .ocr-review-columns,
  .answer-candidate-body {
    grid-template-columns: 1fr;
  }

  .teacher-mode-tabs {
    grid-template-columns: 1fr;
  }

  .teacher-workbench,
  .teacher-guidance-controls,
  .teacher-task-card,
  .question-bank-panel,
  .question-bank-set-card,
  .question-bank-item {
    min-width: 0;
    max-width: 100%;
  }

  .teacher-mode-intro,
  .teacher-ocr-preview-heading,
  .teacher-ocr-effect-heading,
  .question-bank-set-card > header,
  .question-bank-item-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .teacher-ocr-preview-controls {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    width: 100%;
    gap: 6px;
  }

  .teacher-ocr-preview-toolbar {
    width: 100%;
    justify-items: stretch;
  }

  .teacher-ocr-zoom-controls {
    justify-content: center;
    flex-wrap: wrap;
  }

  .teacher-ocr-preview-page-meta {
    width: auto;
    max-width: none;
    text-align: center;
  }

  .teacher-ocr-preview-controls .secondary-btn {
    min-width: 62px;
    padding-inline: 8px;
  }

  .teacher-ocr-preview-controls .field-hint {
    min-width: 0;
    text-align: center;
  }

  .ocr-review-actions,
  .ocr-review-primary-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .ocr-review-actions button,
  .ocr-review-primary-actions button {
    width: 100%;
  }

  .assessment-notes,
  .assessment-submit-row {
    grid-column: 1;
  }

  .assessment-answer-list {
    grid-template-columns: 1fr;
  }

}
