:root {
  --bg: #eef2f6;
  --panel: #ffffff;
  --text: #243040;
  --muted: #6b7280;
  --line: #d7dee8;
  --sidebar: #212529;
  --sidebar-muted: #adb5bd;
  --accent: #0d6efd;
  --accent-dark: #0b5ed7;
  --success: #0f766e;
  --warning: #b45309;
  --danger: #b91c1c;
  --sidebar-width: 280px;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-dark);
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 5;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  padding: 24px 16px 18px;
  overflow-y: auto;
  background: var(--sidebar);
  color: #fff;
}

.sidebar-brand {
  display: block;
  padding: 0 12px;
  color: #fff;
  text-decoration: none;
}

.sidebar-brand:hover {
  color: #fff;
}

.sidebar-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0;
}

.sidebar-sub {
  margin-top: 6px;
  color: var(--sidebar-muted);
  font-size: 12px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 4px;
  color: #f8f9fa;
  font-size: 15px;
  font-weight: 600;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-link.active {
  background: var(--accent);
  color: #fff;
}

.sidebar-link-mark {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: #6c757d;
}

.sidebar-link.active .sidebar-link-mark {
  background: #fff;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.sidebar-footer-title {
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.sidebar-footer-sub {
  margin-top: 5px;
  color: var(--sidebar-muted);
  font-size: 12px;
  line-height: 1.6;
}

.sidebar-footer-sub a {
  color: #fff;
}

.workspace {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
}

.page {
  max-width: 1360px;
  margin: 0 auto;
  padding: 28px 30px 40px;
}

.content-band,
.panel {
  margin-bottom: 20px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.page-head,
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.page-head h1,
.page-head h2,
.page-head h3,
.panel-head h1,
.panel-head h2,
.panel-head h3 {
  margin: 0;
}

.page-head h1,
.panel-head h1 {
  font-size: 28px;
  line-height: 1.25;
}

.page-head h2,
.panel-head h2 {
  font-size: 21px;
  line-height: 1.35;
}

.page-head p,
.panel-head p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.panel-head.inner {
  margin-bottom: 16px;
}

.status-chip,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 5px 11px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-chip.ok,
.badge.status-done {
  border-color: #bbf7d0;
  background: #dcfce7;
  color: #166534;
}

.status-chip.warn,
.badge.status-queued,
.badge.status-processing {
  border-color: #fde68a;
  background: #fef3c7;
  color: #92400e;
}

.badge.status-failed {
  border-color: #fecaca;
  background: #fee2e2;
  color: #991b1b;
}

.student-form {
  margin-top: 4px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 17px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

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

.field label {
  color: #354052;
  font-size: 14px;
  font-weight: 700;
}

input[type="text"],
input[type="password"],
input[type="search"],
input[type="file"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  font: inherit;
  padding: 11px 12px;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="file"]:focus,
select:focus,
textarea:focus {
  border-color: #86b7fe;
  outline: 0;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.14);
}

textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.65;
}

input[type="file"] {
  padding: 10px 12px;
}

input[readonly] {
  background: #f8fafc;
  color: var(--muted);
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mode-option {
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: #354052;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.mode-option:hover {
  border-color: #86b7fe;
  color: var(--accent);
}

.mode-option.active {
  border-color: var(--accent);
  background: #e7f1ff;
  color: var(--accent-dark);
}

.question-picker {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.picker-tools {
  display: grid;
  gap: 13px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.quick-filter {
  display: grid;
  gap: 8px;
}

.quick-filter-label {
  color: #354052;
  font-size: 14px;
  font-weight: 700;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: #354052;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}

.filter-chip:hover {
  border-color: #86b7fe;
  color: var(--accent);
}

.filter-chip.active {
  border-color: var(--accent);
  background: #e7f1ff;
  color: var(--accent-dark);
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.picker-status {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.question-choice-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.question-choice {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 42px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
}

.question-choice:hover {
  border-color: #86b7fe;
}

.question-choice.active {
  border-color: var(--accent);
  background: #e7f1ff;
}

.question-choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.question-choice-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  border-radius: 5px;
  background: #eef2f6;
  color: #354052;
  font-size: 13px;
  font-weight: 800;
}

.question-choice.active .question-choice-number {
  background: var(--accent);
  color: #fff;
}

.question-choice-label {
  min-width: 0;
  overflow: hidden;
  color: #354052;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.answer-upload {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.upload-entry {
  display: flex;
  min-height: 82px;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 14px 16px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: #fbfdff;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.upload-entry:hover {
  border-color: var(--accent);
  background: #f5f9ff;
}

.upload-entry-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
}

.upload-entry-desc {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.upload-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

input[type="file"].upload-input {
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: var(--accent-dark);
  color: #fff;
}

.btn.ghost {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.btn.ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.file-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.file-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.file-thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  object-fit: cover;
}

.file-meta {
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.recent-list {
  display: grid;
  gap: 10px;
}

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.recent-item:hover {
  border-color: #86b7fe;
  background: #fbfdff;
}

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

.recent-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr 160px auto;
  gap: 12px;
  margin-bottom: 16px;
}

.history-table {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.history-head,
.history-row {
  display: grid;
  grid-template-columns: 1.3fr 0.5fr 0.5fr 0.7fr 1fr 0.8fr;
  min-width: 760px;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
}

.history-head {
  background: #f8fafc;
  font-weight: 700;
}

.history-row {
  border-top: 1px solid var(--line);
}

.row-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.text-box,
.log-box {
  width: 100%;
  min-height: 180px;
  max-height: 420px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  white-space: pre-wrap;
  word-break: break-word;
}

.progress-wrap {
  margin: 10px 0 16px;
}

.progress-bar {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}

.progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.progress-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.result-block {
  margin-top: 22px;
}

.hidden {
  display: none;
}

.markdown-body {
  margin-top: 10px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin-top: 1.2em;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol {
  line-height: 1.75;
}

.markdown-body pre {
  overflow: auto;
  padding: 12px;
  border-radius: 6px;
  background: #0f172a;
  color: #e2e8f0;
}

.markdown-body code {
  padding: 2px 4px;
  border-radius: 4px;
  background: #f1f5f9;
}

.file-list {
  margin: 0;
  padding-left: 20px;
  line-height: 1.8;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
}

.error-box {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid #fecaca;
  border-radius: 6px;
  background: #fef2f2;
  color: var(--danger);
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.flash-message {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
}

.flash-message.success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.flash-message.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--danger);
}

.bottom {
  margin-top: 22px;
}

.auth-shell {
  min-height: calc(100vh - 80px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.auth-card h1 {
  margin: 0;
  font-size: 26px;
}

.auth-card p {
  margin: 8px 0 20px;
  color: var(--muted);
  line-height: 1.6;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-form label {
  color: #354052;
  font-size: 14px;
  font-weight: 700;
}

.auth-switch {
  margin-top: 18px;
  color: var(--muted);
  font-size: 14px;
}

.account-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.stat-number {
  font-size: 30px;
  font-weight: 800;
}

.stat-label {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.admin-stats {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.admin-search-row {
  grid-template-columns: minmax(220px, 1fr) 160px 160px auto;
}

.admin-create-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.admin-task-table .history-head,
.admin-task-table .history-row {
  grid-template-columns: 1fr 0.8fr 1.1fr 1fr 1fr 0.8fr;
  min-width: 900px;
}

.admin-user-table .history-head,
.admin-user-table .history-row {
  grid-template-columns: 1fr 1fr 1fr 0.7fr 0.7fr 0.7fr;
  min-width: 820px;
}

.vip-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.vip-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.vip-item span {
  color: var(--muted);
  font-size: 13px;
}

.vip-item strong {
  font-size: 22px;
}

.manual-review-form {
  display: grid;
  gap: 16px;
}

@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: 100%;
    min-height: auto;
    padding: 18px 16px;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    margin-top: 18px;
    padding-top: 14px;
  }

  .sidebar-link {
    flex: 1 1 180px;
  }

  .sidebar-footer {
    display: none;
  }

  .workspace {
    margin-left: 0;
  }

  .page {
    padding: 20px;
  }

  .page-head,
  .panel-head,
  .recent-item {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 14px;
  }

  .content-band,
  .panel {
    padding: 18px;
  }

  .form-grid,
  .picker-grid,
  .two-col,
  .search-row,
  .answer-upload {
    grid-template-columns: 1fr;
  }

  .history-head,
  .history-row {
    min-width: 0;
    grid-template-columns: 1fr;
  }

  .history-head {
    display: none;
  }

  .history-row {
    gap: 7px;
    padding: 14px;
  }

  .field-wide {
    grid-column: auto;
  }

  .actions .btn {
    width: 100%;
  }

  .filter-chip {
    flex: 1 1 auto;
  }

  .mode-switch,
  .question-choice-list {
    grid-template-columns: 1fr;
  }

  .question-choice-label {
    white-space: normal;
  }

  .account-stats {
    grid-template-columns: 1fr;
  }

  .admin-stats,
  .admin-create-form,
  .vip-grid {
    grid-template-columns: 1fr;
  }

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

  .admin-task-table .history-head,
  .admin-task-table .history-row,
  .admin-user-table .history-head,
  .admin-user-table .history-row {
    min-width: 0;
    grid-template-columns: 1fr;
  }
}

/* ===== 搜题面板 ===== */
#searchPanel {
  margin-bottom: 20px;
}

#searchPanel textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.6;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.search-hint {
  color: var(--muted);
  font-size: 13px;
}

.search-results {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.search-result {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: #fff;
}

.search-result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.search-result-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  line-height: 1.4;
}

.search-result-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.search-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}

.search-result-question {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #166534;
}

.search-result-snippet {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  word-break: break-all;
}

.search-result-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}
