:root {
  --ink: #18211f;
  --muted: #64706b;
  --line: #d9e1dc;
  --paper: #f7f4ec;
  --panel: #fffdf7;
  --sage: #497568;
  --mint: #d9eee2;
  --gold: #d59f3a;
  --coral: #ce6d55;
  --blue: #415d86;
  --shadow: 0 18px 50px rgba(36, 45, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(73, 117, 104, 0.12), transparent 36%),
    linear-gradient(315deg, rgba(206, 109, 85, 0.12), transparent 34%),
    var(--paper);
  color: var(--ink);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid rgba(24, 33, 31, 0.12);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--sage);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(30px, 5vw, 54px);
  font-weight: 700;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.status-pill {
  min-width: 92px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  text-align: center;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr) minmax(260px, 340px);
  gap: 22px;
  padding: 24px clamp(18px, 4vw, 48px) 48px;
}

.progress-panel,
.report-panel {
  position: sticky;
  top: 20px;
  align-self: start;
  padding: 18px;
  background: rgba(255, 253, 247, 0.82);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.progress-ring {
  display: grid;
  place-items: center;
  width: 112px;
  aspect-ratio: 1;
  margin-bottom: 14px;
  border: 10px solid var(--mint);
  border-top-color: var(--sage);
  border-radius: 50%;
  color: var(--sage);
  font-size: 24px;
  font-weight: 800;
}

.steps {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.step-link {
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}

.step-link.active {
  border-color: var(--sage);
  background: var(--mint);
  color: var(--ink);
}

.survey {
  display: grid;
  gap: 18px;
}

.section-block,
.submit-band {
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.section-head span {
  display: grid;
  place-items: center;
  width: 38px;
  aspect-ratio: 1;
  background: var(--ink);
  color: var(--paper);
  border-radius: 50%;
  font-weight: 800;
}

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

.field {
  display: grid;
  gap: 8px;
}

.field label,
.question-title {
  color: var(--ink);
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  border-radius: 6px;
}

textarea {
  min-height: 112px;
  resize: vertical;
}

.question {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.question:first-child {
  border-top: 0;
}

.question-number {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  min-height: 24px;
  margin: 0 0 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--mint);
  color: var(--sage);
  font-size: 12px;
  font-weight: 800;
}

.section-note { color: var(--muted); line-height: 1.6; }
.question-image { display: block; width: min(100%, 680px); margin: 12px 0; border: 1px solid var(--line); border-radius: 8px; }
.image-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 12px 0; }
.image-pair img { width: 100%; border: 1px solid var(--line); border-radius: 8px; }
.image-choice-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.image-option span { display: grid; align-content: start; gap: 8px; min-height: 210px; }
.image-option img { width: 100%; max-height: 150px; object-fit: cover; border-radius: 4px; }
.task-card { margin-top: 18px; padding: 18px; border: 1px solid var(--line); background: #fff; }
.task-card h3 { margin: 0 0 8px; }
.task-card fieldset { margin: 16px 0; padding: 14px; border: 1px solid var(--line); }
.task-card legend { padding: 0 6px; font-weight: 800; }
.decision { display: block; margin: 8px 0; padding: 12px; border: 1px solid var(--line); cursor: pointer; }
.decision input { width: auto; min-height: 0; margin-right: 8px; }
.decision small, .permission small { display: block; margin-top: 4px; color: var(--muted); line-height: 1.5; }
.permission { display: grid; grid-template-columns: 150px 1fr auto auto auto; gap: 8px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.permission label { white-space: nowrap; }
.permission input { width: auto; min-height: 0; }
.task-text { display: grid; gap: 8px; margin-top: 14px; font-weight: 700; }
.source-text { padding: 14px; background: #f4f7fb; border-left: 4px solid var(--blue); line-height: 1.7; }
.chat-shell { margin-top: 16px; overflow: hidden; border: 1px solid #c8d8d2; border-radius: 10px; background: #f5faf7; }
.chat-title { display: flex; align-items: center; gap: 8px; padding: 11px 14px; background: var(--sage); color: #fff; }
.chat-title span { color: #f7dd8d; font-size: 18px; }
.chat-title small { margin-left: auto; color: #e4f1ea; font-size: 12px; }
.chat-log { display: grid; gap: 10px; min-height: 118px; padding: 14px; }
.chat-message { max-width: 86%; padding: 10px 12px; border-radius: 12px; line-height: 1.55; }
.chat-message.assistant { justify-self: start; border-bottom-left-radius: 2px; background: #fff; box-shadow: 0 2px 8px rgba(24, 33, 31, 0.08); }
.chat-message.user { justify-self: end; border-bottom-right-radius: 2px; background: #d9eee2; }
.chat-compose { display: grid; gap: 8px; padding: 0 14px 14px; font-weight: 700; }
.draft-button { justify-self: end; min-height: 40px; border: 0; border-radius: 6px; padding: 8px 14px; background: var(--ink); color: #fff; font-weight: 800; cursor: pointer; }
.draft-button:disabled { opacity: .72; cursor: default; }

.scale-row,
.choice-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(54px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.choice-row {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.option {
  min-height: 44px;
}

.option input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.option span {
  display: grid;
  place-items: center;
  min-height: 44px;
  padding: 8px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
}

.option input:checked + span {
  border-color: var(--sage);
  background: var(--mint);
  color: var(--ink);
  font-weight: 800;
}

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

.rubric-list .option span {
  justify-content: start;
  text-align: left;
}

.task-prompt {
  color: var(--muted);
  line-height: 1.7;
}

.review-note {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-left: 4px solid var(--blue);
  background: #f4f7fb;
  color: var(--blue);
  line-height: 1.6;
  font-weight: 700;
}

.submit-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-color: rgba(73, 117, 104, 0.3);
}

#submitButton {
  min-width: 150px;
  min-height: 48px;
  border: 0;
  background: var(--sage);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
}

#submitButton:disabled {
  background: #a9b4af;
  cursor: progress;
}

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

.score-card {
  display: grid;
  gap: 4px;
  padding: 16px;
  border-left: 6px solid var(--gold);
  background: #fff;
}

.score-card strong {
  font-size: 44px;
  line-height: 1;
  font-family: Georgia, "Songti SC", serif;
}

.score-card small {
  color: var(--blue);
  font-weight: 800;
}

pre {
  min-height: 260px;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: #26312e;
  line-height: 1.7;
  font-family: "Menlo", "Consolas", "PingFang SC", monospace;
  font-size: 13px;
}

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

  .progress-panel,
  .report-panel {
    position: static;
  }

  .progress-panel {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px;
  }

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

@media (max-width: 640px) {
  .topbar,
  .submit-band {
    align-items: stretch;
    flex-direction: column;
  }

  .field-grid,
  .scale-row,
  .choice-row,
  .image-choice-row,
  .steps {
    grid-template-columns: 1fr;
  }

  .image-pair { grid-template-columns: 1fr; }
  .permission { grid-template-columns: 1fr; }
  .chat-title { align-items: flex-start; flex-wrap: wrap; }
  .chat-title small { width: 100%; margin-left: 26px; }
  .chat-message { max-width: 96%; }

  .section-block,
  .submit-band,
  .progress-panel,
  .report-panel {
    padding: 16px;
  }
}
.empty-hint { color: #6b6256; background: #fbf6ec; border: 1px dashed #d6c79c; border-radius: 8px; padding: 12px 14px; font-size: 14px; line-height: 1.6; }
.empty-hint code { background: #f0e6cf; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.fatal-error { white-space: pre-wrap; word-break: break-word; background: #fff1f0; color: #8a1f11; border: 1px solid #f5c2c0; border-radius: 8px; padding: 12px 14px; margin: 12px 24px; font-size: 12px; max-height: 240px; overflow: auto; }

/* ===== v3 新题型样式 ===== */
.open-text { width: 100%; min-height: 96px; border: 1px solid #d6c79c; border-radius: 8px; padding: 10px 12px; font: inherit; line-height: 1.6; resize: vertical; box-sizing: border-box; }
.open-text:focus { outline: none; border-color: var(--sage, #1F5B4C); box-shadow: 0 0 0 2px rgba(31,91,76,.12); }
.choice-row.multi .option { border-style: dashed; }
.sub-item { margin: 14px 0 6px; padding: 12px 14px; background: #fbf6ec; border: 1px solid #eadfc4; border-radius: 10px; }
.sub-q { font-weight: 600; margin: 0 0 8px; color: #3a352c; }
.match-row { display: flex; align-items: center; gap: 12px; margin: 8px 0; flex-wrap: wrap; }
.match-stem { flex: 1 1 200px; font-weight: 600; color: #3a352c; }
.match-row select { flex: 0 1 320px; padding: 8px 10px; border: 1px solid #d6c79c; border-radius: 8px; font: inherit; }
.media-gallery { display: flex; gap: 12px; flex-wrap: wrap; margin: 10px 0; }
.media-gallery figure, .card-row figure { margin: 0; max-width: 240px; }
.media-gallery img, .card-row img { width: 100%; border-radius: 8px; border: 1px solid #eadfc4; display: block; }
.media-gallery figcaption, .card-row figcaption { font-size: 13px; color: #6b6256; margin-top: 4px; }
.card-row { display: flex; gap: 14px; flex-wrap: wrap; margin: 12px 0; }
.media-block { margin: 12px 0; }
.media-block video, .media-block audio { max-width: 100%; }
.media-note { font-size: 13px; color: #8a6d3b; background: #fbf6ec; border: 1px dashed #d6c79c; border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
.matrix { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 14px; }
.matrix th, .matrix td { border: 1px solid #e3d8bd; padding: 8px 10px; text-align: center; }
.matrix th.row-head, .matrix thead th { text-align: left; background: #fbf6ec; color: #3a352c; font-weight: 600; }
.matrix td label { display: inline-flex; align-items: center; gap: 4px; }
