:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-soft: #eef5f2;
  --ink: #20252b;
  --muted: #64717c;
  --line: #d7e0e6;
  --green: #24765a;
  --green-deep: #18543f;
  --blue: #235f9d;
  --amber: #a76f16;
  --red: #b5483f;
  --shadow: 0 16px 34px rgba(24, 34, 43, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: linear-gradient(180deg, rgba(35, 95, 157, 0.08), transparent 280px), var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  width: min(1360px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 38px;
}

.topbar,
.console,
.paper-toolbar,
.question-head,
.panel-head,
.top-actions,
.toolbar-actions,
.learner-row {
  display: flex;
  gap: 12px;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  padding-bottom: 18px;
}

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

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius);
  background: var(--green-deep);
  color: #fff;
  font-weight: 900;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

h1 {
  margin-bottom: 0;
  font-size: 1.6rem;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.top-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

.version {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  color: var(--muted);
  background: #fff;
  font-size: 0.86rem;
}

.btn {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.btn.primary {
  border-color: var(--green-deep);
  background: var(--green-deep);
  color: #fff;
}

.btn.compact {
  min-height: 36px;
  padding: 6px 10px;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.link-btn {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 800;
}

.console {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 310px;
  align-items: start;
}

.left-rail,
.right-rail {
  display: grid;
  gap: 14px;
}

.learner-panel,
.nav-panel,
.score-panel,
.source-panel,
.history-panel,
.question-card,
.paper-toolbar {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.learner-panel,
.nav-panel,
.score-panel,
.source-panel,
.history-panel {
  padding: 14px;
}

.learner-panel label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.learner-row {
  align-items: center;
}

.learner-row input {
  min-width: 0;
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
}

.learner-panel p,
.source-info,
.record-list,
.muted {
  color: var(--muted);
  font-size: 0.92rem;
}

.panel-head {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

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

.type-counts div,
.score-grid div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px;
  background: #fff;
}

.type-counts span,
.score-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.type-counts strong,
.score-grid strong {
  color: var(--green-deep);
  font-size: 1.1rem;
}

.question-nav {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
}

.nav-item {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

.nav-item strong,
.nav-item span {
  display: block;
}

.nav-item span {
  color: var(--muted);
  font-size: 0.78rem;
}

.nav-item.current {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 2px rgba(35, 95, 157, 0.18);
}

.nav-item.answered {
  background: var(--panel-soft);
}

.nav-item.wrong {
  border-color: rgba(181, 72, 63, 0.45);
  background: #fff2f1;
}

.workspace {
  min-width: 0;
}

.paper-toolbar {
  position: sticky;
  top: 0;
  z-index: 4;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 12px;
}

.paper-toolbar span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

.toolbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.question-stage {
  min-height: 560px;
}

.question-card {
  padding: 18px;
}

.question-head {
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.question-head span {
  color: var(--muted);
  font-size: 0.9rem;
}

.question-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.question-tags span,
.source-chip {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--blue);
  background: #edf4fb;
  font-size: 0.86rem;
  font-weight: 800;
}

.stem {
  white-space: pre-wrap;
  font-weight: 800;
}

.source-alert {
  margin: 12px 0;
  border: 1px solid rgba(167, 111, 22, 0.28);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #fbf4e6;
  color: #704b0f;
}

.source-alert a,
.source-info a {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

.options,
.criteria-list {
  display: grid;
  gap: 9px;
}

.option,
.criterion {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #fff;
}

.option input,
.criterion input {
  width: 18px;
  height: 18px;
  margin: 4px 0 0;
  accent-color: var(--green-deep);
}

.option.correct,
.criterion.checked {
  border-color: rgba(36, 118, 90, 0.55);
  background: #eef8f3;
}

.option.wrong {
  border-color: rgba(181, 72, 63, 0.55);
  background: #fff2f1;
}

.task-note {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.task-note textarea {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}

.review-box,
.pending-note,
.empty-state,
.record-summary {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
}

.review-box {
  background: #f8fbf9;
}

.review-grid {
  display: grid;
  gap: 10px;
}

.ok {
  color: var(--green-deep);
  font-weight: 900;
}

.bad {
  color: var(--red);
  font-weight: 900;
}

.answer-compare,
.explain-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #fff;
}

.explain-card pre {
  overflow-x: auto;
  white-space: pre-wrap;
}

.score-ring {
  display: grid;
  width: 148px;
  height: 148px;
  place-items: center;
  margin: 4px auto 14px;
  border-radius: 50%;
  background: conic-gradient(var(--green) var(--score-angle, 0deg), #e1e8ec 0), #e1e8ec;
}

.score-inner {
  display: grid;
  width: 112px;
  height: 112px;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  text-align: center;
}

.score-inner span {
  display: block;
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
}

.score-inner small {
  color: var(--muted);
}

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

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

.record-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #fff;
  text-align: left;
}

.record-item strong,
.record-item span {
  display: block;
}

.record-item span {
  color: var(--muted);
  font-size: 0.86rem;
}

.record-dialog {
  width: min(900px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

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

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

.record-question {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #fff;
}

.record-question.bad-line {
  border-color: rgba(181, 72, 63, 0.45);
}

@media (max-width: 1120px) {
  .console {
    grid-template-columns: 1fr;
  }

  .left-rail,
  .right-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-panel,
  .history-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 18px, 1360px);
    padding-top: 14px;
  }

  .topbar,
  .paper-toolbar,
  .question-head,
  .left-rail,
  .right-rail {
    display: block;
  }

  .top-actions,
  .toolbar-actions {
    justify-content: flex-start;
    margin-top: 10px;
  }

  .question-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .score-grid,
  .type-counts {
    grid-template-columns: 1fr;
  }
}
