:root {
  --bg: #f4f6f9;
  --surface: #fff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow: hidden; }

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

#app { height: 100%; }

.view { display: none; height: 100%; }
.view.active { display: flex; flex-direction: column; }
#view-tasks.active {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.page-header { padding: 1.5rem 1.25rem .75rem; text-align: center; }
.page-header h1 { font-size: 1.45rem; margin-bottom: .35rem; }
.subtitle { color: var(--muted); font-size: .88rem; max-width: 42rem; margin: 0 auto; }
.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  max-width: 42rem;
  margin: 0 auto .85rem;
}

#view-mode.active {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.mode-gate {
  width: min(720px, 100%);
  margin: 1rem auto 2.5rem;
  padding: 0 1.25rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .55rem;
  text-align: left;
  padding: 1.35rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
  color: inherit;
  font: inherit;
}
.mode-card:hover {
  border-color: var(--primary);
  background: #eff6ff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, .08);
}
.mode-card-label {
  font-size: 1.15rem;
  font-weight: 700;
}
.mode-card-desc {
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.45;
}

.mode-badge {
  font-variant-numeric: tabular-nums;
}
.mode-badge.is-preview {
  background: #fff7ed;
  color: #c2410c;
}
.mode-badge.is-formal {
  background: #eff6ff;
  color: #1d4ed8;
}

@media (max-width: 640px) {
  .mode-gate { grid-template-columns: 1fr; }
}

.task-list {
  width: min(1180px, 100%);
  margin: 0 auto 2rem;
  padding: 0 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.task-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem 1rem;
}
.task-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .75rem;
  padding-bottom: .55rem;
  border-bottom: 1px solid var(--border);
}
.task-group-head h2 {
  font-size: 1rem;
  font-weight: 650;
  min-width: 0;
  word-break: break-all;
}
.task-group-summary {
  color: var(--muted);
  font-size: .78rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .55rem;
}

.task-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: .7rem .8rem;
  cursor: pointer;
  transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
  min-width: 0;
}
.task-card:hover {
  border-color: var(--primary);
  background: #eff6ff;
  box-shadow: 0 1px 0 rgba(37, 99, 235, .08);
}
.task-card h3 {
  font-size: .88rem;
  font-weight: 600;
  margin-bottom: .3rem;
  line-height: 1.3;
  word-break: break-word;
}
.task-card .meta { color: var(--muted); font-size: .75rem; }
.task-card .meta-row {
  display: flex;
  justify-content: space-between;
  gap: .4rem;
  margin-top: .15rem;
}
.task-card .pct {
  color: var(--success);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.task-card .pct-warn { color: var(--warning); }
.task-card .meta-arb { margin-top: .35rem; }
.progress-bar { height: 4px; background: var(--border); border-radius: 2px; margin-top: .35rem; overflow: hidden; }
.progress-fill { height: 100%; background: var(--success); }
.progress-bar-arb { margin-top: .25rem; }
.progress-fill-arb { background: var(--warning); }

.empty-hint { text-align: center; color: var(--muted); padding: 2rem; }

#view-review.active { height: 100vh; overflow: hidden; }

.toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .4rem .75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: .5rem;
}
.toolbar-center { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; min-width: 0; }
.toolbar-actions { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.task-title { font-weight: 600; font-size: .88rem; }
.badge {
  background: #eff6ff;
  color: var(--primary);
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .72rem;
}
.badge-muted { background: #f1f5f9; color: var(--muted); }

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: .35rem .7rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: .82rem;
  white-space: nowrap;
}
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { filter: brightness(1.05); }
.btn-ghost { border: none; background: transparent; color: var(--primary); }
.btn-sm { padding: .28rem .55rem; font-size: .78rem; }

.review-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .35rem .6rem 0;
}
.record-meta {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .3rem .55rem;
  font-size: .75rem;
  display: flex;
  flex-wrap: wrap;
  gap: .25rem .85rem;
}
.record-meta strong { color: var(--muted); font-weight: 500; }

.question-panel {
  flex-shrink: 0;
  margin: .35rem .6rem 0;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: var(--radius);
  padding: .4rem .6rem;
  max-height: 6.5rem;
  overflow-y: auto;
}
.question-label {
  font-size: .7rem;
  font-weight: 600;
  color: #0369a1;
  margin-bottom: .2rem;
}
.question-content { font-size: .8rem; line-height: 1.4; }

/* 三栏：学号 | 原图 | 模型上下 */
.review-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 168px minmax(0, 1.15fr) minmax(0, 1fr);
  gap: .45rem;
  padding: .45rem .6rem;
  overflow: hidden;
}

.record-nav {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.nav-title {
  flex-shrink: 0;
  padding: .45rem .55rem;
  font-size: .78rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.filter-group {
  padding: .4rem .5rem;
  border-bottom: 1px solid var(--border);
}
.nav-filters { display: flex; gap: .2rem; }
.filter-btn {
  flex: 1;
  padding: .28rem .15rem;
  font-size: .68rem;
  border: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 5px;
  cursor: pointer;
}
.filter-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.filter-select {
  width: 100%;
  padding: .3rem .35rem;
  font-size: .72rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #f8fafc;
}

.record-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.record-list-pager {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .35rem;
  padding: .35rem .45rem;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  font-size: .7rem;
}
.record-list-pager .list-page-info {
  color: var(--muted);
  flex: 1;
  text-align: center;
}
.record-list li {
  padding: .45rem .5rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: .78rem;
}
.record-list li:hover { background: #f8fafc; }
.record-list li.active { background: #eff6ff; border-left: 3px solid var(--primary); }
.record-list .rec-id { font-weight: 600; font-variant-numeric: tabular-nums; }
.record-list .rec-sub { color: var(--muted); font-size: .68rem; margin-top: .1rem; }
.record-list .rec-badges { display: flex; gap: .25rem; margin-top: .2rem; flex-wrap: wrap; }
.mini-tag {
  font-size: .62rem;
  padding: .05rem .3rem;
  border-radius: 3px;
}
.mini-tag.done { background: #dcfce7; color: var(--success); }
.mini-tag.arb-ok { background: #dcfce7; color: var(--success); }
.mini-tag.arb-no { background: #fef3c7; color: var(--warning); }

.pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
.pane-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .4rem;
  padding: .4rem .55rem;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.pane-header h2 {
  font-size: .82rem;
  font-weight: 600;
}

.pane-image { min-height: 0; }
.image-gallery {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6rem;
  padding: .55rem;
}
.image-gallery .gallery-item {
  margin: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
}
.image-gallery .gallery-item figcaption {
  font-size: .72rem;
  color: var(--muted);
}
.image-gallery img {
  max-width: 100%;
  max-height: none;
  width: auto;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: zoom-in;
  background: #fafafa;
}

.pane-models {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: .45rem;
  min-height: 0;
  min-width: 0;
  background: transparent;
  border: none;
}
.model-pane { min-height: 0; }

.single-model-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.model-panel-header {
  display: none; /* 采用按钮已移到 pane-header */
}
.model-panel-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  font-size: .84rem;
  line-height: 1.6;
  padding: .45rem .55rem;
}

.status-tag {
  font-size: .72rem;
  padding: .12rem .45rem;
  border-radius: 999px;
  font-weight: 500;
}
.status-tag.consistent { background: #dcfce7; color: var(--success); }
.status-tag.inconsistent { background: #fef3c7; color: var(--warning); }
#arb-status-chip { cursor: pointer; }

.report-box {
  font-size: .85rem;
  line-height: 1.65;
}

.review-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: .35rem .6rem .45rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  max-height: 34vh;
  min-height: 0;
}
.final-compact {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  min-height: 0;
  flex: 1;
}
.final-compact-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  font-size: .8rem;
}
.inline-label { font-size: .75rem; display: flex; align-items: center; gap: .3rem; }
#base-model-select { font-size: .72rem; padding: .15rem .3rem; border: 1px solid var(--border); border-radius: 4px; }

.editor-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .4rem;
  min-height: 0;
  flex: 1;
}
#final-markdown {
  width: 100%;
  min-height: 72px;
  height: 100%;
  padding: .4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: ui-monospace, monospace;
  font-size: .76rem;
  line-height: 1.5;
  resize: none;
}
.preview-wrap {
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  min-height: 72px;
  overflow: hidden;
}
.preview-label {
  flex-shrink: 0;
  background: #f8fafc;
  padding: .15rem .4rem;
  font-size: .68rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.markdown-preview {
  flex: 1;
  overflow: auto;
  padding: .4rem;
  font-size: .8rem;
  line-height: 1.55;
}

.md-content { word-break: break-word; }
.md-content p { margin: .3em 0; }
.md-content .katex-display { margin: .4em 0; overflow-x: auto; }
.md-fallback {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, monospace;
  font-size: .78rem;
  line-height: 1.5;
  margin: 0;
}
.empty-inline { color: var(--muted); font-size: .82rem; }

.bottom-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  flex-wrap: wrap;
}
.bottom-tags {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-size: .75rem;
}
.bottom-tags label { display: flex; align-items: center; gap: .2rem; cursor: pointer; }
.reviewer-input {
  width: 84px;
  padding: .2rem .35rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: .72rem;
}
.bottom-nav { display: flex; gap: .3rem; flex-wrap: wrap; }

/* 仲裁弹窗 */
.modal[hidden] { display: none !important; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .45);
}
.modal-panel {
  position: relative;
  z-index: 1;
  width: min(720px, 94vw);
  max-height: min(80vh, 720px);
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(15, 23, 42, .25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .7rem .85rem;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.modal-header h2 {
  font-size: .95rem;
  margin-right: auto;
}
.modal-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: .85rem 1rem 1.1rem;
}

.toast {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  padding: .5rem 1rem;
  border-radius: 6px;
  font-size: .82rem;
  z-index: 100;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  cursor: zoom-out;
}
.lightbox img { max-width: 96vw; max-height: 96vh; object-fit: contain; }

@media (max-width: 1100px) {
  .review-layout {
    grid-template-columns: 148px minmax(0, 1fr) minmax(0, 1fr);
  }
}
@media (max-width: 820px) {
  .review-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 140px minmax(180px, 1fr) minmax(220px, 1fr);
    overflow-y: auto;
  }
  .pane-models { grid-template-rows: 1fr 1fr; min-height: 280px; }
  .editor-split { grid-template-columns: 1fr; }
  .review-footer { max-height: none; }
}
