:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-soft: #f0f4f8;
  --text: #172033;
  --muted: #667085;
  --line: #dde3ec;
  --blue: #2563eb;
  --green: #10a36f;
  --amber: #f59e0b;
  --red: #e5484d;
  --ink: #111827;
  --shadow: 0 18px 45px rgba(20, 31, 54, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

input[type="password"] {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  background: #111827;
  color: #fff;
}

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

.brand-mark,
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #2dd4bf;
  color: #07111f;
  font-weight: 800;
}

.brand-mark,
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  line-height: 1;
  text-align: center;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: #fff;
  font-size: 16px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.student-avatar {
  background: linear-gradient(135deg, #2563eb, #14b8a6);
}

.admin-avatar {
  background: linear-gradient(135deg, #7c3aed, #db2777);
}

.brand span,
.user-pill span,
.sidebar-card span,
.meta,
.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.brand span,
.sidebar-card span {
  color: #bac4d2;
}

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

.nav-item,
.ghost-button {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 14px;
  background: transparent;
  color: #d8dee9;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: #263244;
  color: #fff;
}

.sidebar-card {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid #2f3b4f;
  border-radius: 8px;
  background: #172033;
}

.ghost-button {
  border-color: #3c485c;
  text-align: center;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

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

h1 {
  font-size: 30px;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 16px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 230px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.user-pill > div {
  min-width: 0;
}

.user-pill strong,
.user-pill span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-area {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.view-root {
  display: grid;
  gap: 18px;
}

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

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

.teacher-grid {
  grid-template-columns: 1.1fr 0.9fr;
}

.teacher-layout {
  display: grid;
  gap: 18px;
}

.paper-form-grid {
  display: grid;
  grid-template-columns: 1.5fr repeat(3, minmax(130px, 0.5fr));
  gap: 12px;
}

.card,
.section-block,
.stat-card,
.question-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.section-block {
  border: 0;
  box-shadow: none;
  background: transparent;
}

.stat-card {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.stat-card strong {
  font-size: 28px;
}

.card {
  padding: 18px;
}

.section-header,
.filters,
.paper-head,
.exam-head,
.exam-footer,
.answer-row,
.result-row,
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.published-paper-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
}

.paper-select-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.paper-select-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.filters {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.filter-group {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.filter-label {
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
}

.chip,
.tag,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
}

button.chip {
  border: 0;
  cursor: pointer;
}

.chip.active {
  background: #dbeafe;
  color: var(--blue);
}

.tag.green {
  background: #dcfce7;
  color: #047857;
}

.tag.amber {
  background: #fef3c7;
  color: #b45309;
}

.paper-card {
  display: grid;
  gap: 14px;
  min-height: 150px;
}

.card:has(.filter-group) .section-header,
.paper-card p {
  display: none;
}

.teacher-layout > .card:first-child .section-header .meta,
.teacher-layout > .card:nth-child(2) .section-header .meta {
  display: none;
}

.paper-card p,
.question-card p,
.empty {
  color: var(--muted);
  line-height: 1.7;
}

.primary-button,
.secondary-button,
.danger-button {
  border: 0;
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
  color: #fff;
  background: var(--blue);
  font-weight: 700;
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: #fff;
}

.danger-button {
  background: var(--red);
}

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

.bulk-user-input {
  min-height: 170px;
  margin-top: 12px;
  font-family: Consolas, "Courier New", monospace;
}

.compact-select {
  width: auto;
  min-width: 128px;
}

.user-list-card {
  overflow: hidden;
}

.user-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.user-search {
  width: min(330px, 100%);
  min-height: 44px;
  padding: 8px 12px;
}

.user-page-size {
  min-width: 118px;
}

.user-table {
  display: grid;
  margin-top: 14px;
  overflow-x: hidden;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.85fr) minmax(112px, 0.95fr) minmax(150px, 1.1fr) minmax(132px, 0.95fr) minmax(116px, 0.85fr) 62px 224px;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.user-row-header {
  min-height: 38px;
  padding-top: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.user-row.disabled {
  opacity: 0.64;
}

.user-username,
.user-status {
  min-width: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.user-row input,
.user-row select {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  font-weight: 700;
}

.row-actions.user-row-actions {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  gap: 8px;
  justify-content: flex-start;
  align-items: center;
  min-width: 0;
  flex-wrap: nowrap;
}

.row-actions.user-row-actions button {
  min-width: 0;
  min-height: 40px;
  padding: 0 8px;
  font-size: 14px;
}

.user-row-actions button:disabled,
.user-row select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.user-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 14px;
}

.user-pagination button {
  min-width: 92px;
}

.student-answer-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.student-answer-search {
  width: min(260px, 100%);
  min-height: 44px;
  padding: 8px 12px;
}

.student-answer-table {
  display: grid;
  overflow-x: hidden;
}

.student-answer-row {
  display: grid;
  grid-template-columns: minmax(260px, 1.05fr) minmax(140px, 0.7fr) minmax(72px, 0.28fr) 88px;
  gap: 12px;
  align-items: center;
  min-width: 0;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.student-answer-header {
  min-height: 38px;
  padding-top: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.student-answer-row > * {
  min-width: 0;
}

.row-actions.student-answer-actions {
  display: flex;
  justify-content: flex-start;
  flex-wrap: nowrap;
}

.row-actions.student-answer-actions button {
  min-width: 72px;
  padding: 0 12px;
}

.wrong-table {
  display: grid;
  overflow-x: hidden;
}

.wrong-row {
  display: grid;
  grid-template-columns: 64px minmax(260px, 1.3fr) minmax(120px, 0.5fr) 180px;
  gap: 12px;
  align-items: center;
  min-width: 0;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.wrong-row.manager {
  grid-template-columns: 64px minmax(100px, 0.45fr) minmax(110px, 0.5fr) minmax(260px, 1.2fr) minmax(120px, 0.48fr) 112px;
}

.wrong-header {
  min-height: 38px;
  padding-top: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.wrong-row > * {
  min-width: 0;
}

.wrong-title {
  max-height: 76px;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.5;
}

.wrong-title img {
  max-width: 120px;
  max-height: 72px;
  object-fit: contain;
}

.row-actions.wrong-actions {
  justify-content: flex-start;
  flex-wrap: nowrap;
}

.row-actions.wrong-actions button {
  min-width: 76px;
  padding: 0 10px;
}

.wrong-detail-panel {
  width: min(980px, 94vw);
  padding: 26px;
}

.wrong-detail-root {
  display: grid;
  gap: 18px;
}

.wrong-detail-section {
  display: grid;
  gap: 10px;
}

.wrong-detail-section h3 {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.wrong-detail-title,
.wrong-detail-options {
  display: grid;
  gap: 10px;
}

.wrong-detail-option {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.list-row {
  min-height: 56px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.draft-question-row {
  align-items: flex-start;
}

.draft-question-preview {
  display: grid;
  flex: 1 1 auto;
  min-width: 0;
  gap: 6px;
}

.draft-question-title {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.draft-question-title p {
  margin: 0 0 8px;
}

.draft-question-title img {
  display: block;
  width: auto;
  max-width: 360px;
  max-height: 220px;
  object-fit: contain;
}

.draft-question-index {
  font-weight: 800;
}

.draft-question-actions {
  flex: 0 0 auto;
  min-width: 112px;
}

.list-row:last-child {
  border-bottom: 0;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.55);
}

.modal.hidden {
  display: none;
}

.modal-panel {
  position: relative;
  width: min(1100px, 96vw);
  max-height: 92vh;
  overflow: auto;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.exam-panel {
  width: calc(100vw - 32px);
  height: calc(100vh - 32px);
  max-height: calc(100vh - 32px);
  padding: 22px;
}

.exam-panel #examRoot {
  min-height: 100%;
}

.close-modal {
  position: absolute;
  top: 12px;
  right: 12px;
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 22px;
}

.exam-layout {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 18px;
  margin-top: 18px;
}

.exam-action-row {
  display: flex;
  justify-content: center;
  padding-top: 16px;
  margin-top: 4px;
  border-top: 1px solid var(--line);
}

.exam-action-row .primary-button {
  min-width: 180px;
  min-height: 46px;
}

.submit-paper-button {
  background: var(--green);
}

.question-card {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.option input {
  margin-top: 4px;
}

.answer-sheet {
  display: grid;
  gap: 10px;
  align-content: start;
}

.question-number-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.question-number {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.question-number.active {
  border-color: var(--blue);
  color: var(--blue);
}

.question-number.done {
  background: #dcfce7;
  color: #047857;
}

.question-number.correct {
  border-color: #10a36f;
  background: #dcfce7;
  color: #047857;
}

.question-number.wrong {
  border-color: #e5484d;
  background: #fee2e2;
  color: #b91c1c;
}

.question-number.manual {
  border-color: #f59e0b;
  background: #fef3c7;
  color: #b45309;
}

.result-row.correct {
  color: var(--green);
}

.result-row.wrong {
  color: var(--red);
}

.submit-banner {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  background: #f0fdf4;
  color: #047857;
  font-weight: 700;
}

.question-images {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.question-images img {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.scratch-panel {
  width: min(1180px, 96vw);
}

.scratch-workspace {
  display: grid;
  grid-template-columns: 1fr 320px;
  min-height: 680px;
}

.scratch-stage {
  display: grid;
  grid-template-rows: auto 1fr;
  background: #222733;
  color: #fff;
}

.stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stage-preview {
  display: grid;
  place-items: center;
  gap: 18px;
  padding: 28px;
  text-align: center;
}

.cat-face {
  position: relative;
  width: 160px;
  height: 120px;
  border-radius: 48px 48px 36px 36px;
  background: #ffb43b;
}

.cat-face::before,
.cat-face::after {
  content: "";
  position: absolute;
  top: -34px;
  width: 54px;
  height: 54px;
  background: #ffb43b;
  transform: rotate(45deg);
}

.cat-face::before {
  left: 22px;
}

.cat-face::after {
  right: 22px;
}

.cat-face span {
  position: absolute;
  top: 48px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #111827;
}

.cat-face span:first-child {
  left: 48px;
}

.cat-face span:last-child {
  right: 48px;
}

.scratch-side {
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 28px 22px;
}

.file-drop {
  display: grid;
  place-items: center;
  min-height: 120px;
  border: 1px dashed #9aa8bc;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
}

.file-drop input {
  display: none;
}

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

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

.form-grid {
  display: grid;
  gap: 12px;
}

.field-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.rich-editor {
  min-height: 92px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  line-height: 1.7;
  outline: none;
}

.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: #98a2b3;
}

.rich-editor:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.rich-toolbar button {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.rich-toolbar button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.rich-toolbar .color-dot {
  width: 30px;
  min-width: 30px;
  padding: 0;
}

.rich-toolbar .color-dot::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.2);
}

.rich-toolbar .color-dot.ink::before {
  background: #111827;
}

.rich-toolbar .color-dot.red::before {
  background: #dc2626;
}

.rich-toolbar .color-dot.blue::before {
  background: #2563eb;
}

.rich-editor img,
.question-title img {
  max-width: 100%;
  height: auto;
  display: inline-block;
  vertical-align: middle;
  margin: 6px 8px 6px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: contain;
}

.option-content img {
  max-width: 100%;
  max-height: 280px;
  display: inline-block;
  vertical-align: middle;
  margin: 6px 8px 6px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: contain;
}

.rich-editor img.selected-rich-image {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.question-card > .question-title img[style*="width"] {
  height: auto;
}

.question-card > .question-images {
  grid-template-columns: repeat(auto-fit, minmax(180px, max-content));
}

.question-card > .question-images img {
  height: auto;
}

.image-placeholder {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
}

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

.option-editor {
  display: grid;
  gap: 8px;
}

.option-editor > span,
.option-key {
  color: var(--blue);
  font-weight: 800;
}

.option-rich-editor {
  min-height: 76px;
}

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

.judge-option {
  display: grid;
  place-items: center;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  font-weight: 800;
}

.question-title {
  font-size: 17px;
  font-weight: 400;
  line-height: 1.75;
}

.option-content {
  flex: 1;
  min-width: 0;
}

.rich-editor pre,
.question-title pre,
.option-content pre,
.scratch-requirement pre {
  margin: 12px 0;
  padding: 16px 18px;
  border-radius: 8px;
  background: #20241f;
  color: #7dd3fc;
  overflow-x: auto;
  font-size: 16px;
  line-height: 1.65;
  font-family: Consolas, "Courier New", monospace;
  font-weight: 600;
}

.rich-editor code,
.question-title code,
.option-content code,
.scratch-requirement code {
  font-family: Consolas, "Courier New", monospace;
}

.rich-editor :not(pre) > code,
.question-title :not(pre) > code,
.option-content :not(pre) > code,
.scratch-requirement :not(pre) > code {
  padding: 2px 6px;
  border-radius: 5px;
  background: #e8f1ff;
  color: #1d4ed8;
}

.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.auth-panel {
  width: min(420px, 94vw);
  padding: 22px;
}

.form-message {
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
}

.upload-box {
  display: grid;
  place-items: center;
  min-height: 104px;
  border: 1px dashed #9aa8bc;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
}

.upload-box input {
  display: none;
}

.import-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.import-button input {
  display: none;
}

.image-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.image-chip {
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  min-width: 240px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 960px) {
  .app-shell,
  .exam-layout,
  .scratch-workspace,
  .teacher-grid,
  .paper-form-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

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

  .user-table {
    overflow-x: auto;
  }

  .user-row {
    min-width: 920px;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 18px;
  }

  .topbar,
  .section-header,
  .paper-head,
  .exam-footer {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .option-editor-grid {
    grid-template-columns: 1fr;
  }

}

.sidebar-card p {
  margin: 0;
  color: #bac4d2;
  font-size: 13px;
  line-height: 1.6;
}

.scratch-panel {
  width: min(1380px, 98vw);
}

.scratch-workspace {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 760px;
}

.scratch-question {
  display: grid;
  gap: 16px;
  align-content: start;
  padding: 28px 24px;
  border-right: 1px solid var(--line);
  background: #fff;
}

.scratch-question p {
  color: var(--muted);
  line-height: 1.75;
}

.scratch-requirement {
  color: var(--ink);
  font-weight: 400;
  line-height: 1.75;
}

.scratch-requirement img {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  margin: 10px 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.question-tip {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 8px;
  background: #f8fafc;
}

.question-tip span {
  color: var(--muted);
  font-size: 14px;
}

.scratch-editor {
  display: grid;
  grid-template-rows: 58px 1fr;
  min-width: 0;
  background: #eef3fb;
}

.scratch-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid #cbd5e1;
  background: #fff;
}

.scratch-toolbar div {
  display: flex;
  gap: 8px;
}

.green-flag,
.stop-button {
  width: 38px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
}

.green-flag {
  background: var(--green);
}

.stop-button {
  background: var(--red);
}

.scratch-body {
  display: grid;
  grid-template-columns: 210px 1fr 360px;
  gap: 12px;
  min-height: 0;
  padding: 12px;
}

.block-palette,
.script-area,
.stage-area {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
}

.block-palette {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
}

.block {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  color: #fff;
  text-align: left;
  font-weight: 700;
}

.motion {
  background: #4c97ff;
}

.event {
  background: #ffbf00;
  color: #382a00;
}

.control {
  background: #ffab19;
  color: #3d2700;
}

.looks {
  background: #9966ff;
}

.script-area {
  display: flex;
  align-content: flex-start;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px;
  overflow: auto;
}

.drop-hint {
  color: var(--muted);
}

.stage-area {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 12px;
  padding: 12px;
}

.stage {
  position: relative;
  overflow: hidden;
  min-height: 360px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: linear-gradient(#dbeafe, #f8fafc 62%);
}

.scratch-cat {
  position: absolute;
  left: 28px;
  bottom: 68px;
  width: 96px;
  height: 72px;
  border-radius: 28px 28px 22px 22px;
  background: #ffb43b;
  transition: transform 1.2s ease;
}

.scratch-cat.run {
  transform: translateX(210px);
}

.scratch-cat::before,
.scratch-cat::after {
  content: "";
  position: absolute;
  top: -20px;
  width: 34px;
  height: 34px;
  background: #ffb43b;
  transform: rotate(45deg);
}

.scratch-cat::before {
  left: 14px;
}

.scratch-cat::after {
  right: 14px;
}

.scratch-cat span {
  position: absolute;
  top: 30px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #111827;
}

.scratch-cat span:first-child {
  left: 28px;
}

.scratch-cat span:last-child {
  right: 28px;
}

@media (max-width: 1100px) {
  .scratch-workspace,
  .scratch-body {
    grid-template-columns: 1fr;
  }
}

.scratch-panel {
  width: 100vw;
  height: 100vh;
  max-height: none;
  padding: 0;
  border-radius: 0;
  overflow: hidden;
}

#scratchModal {
  padding: 0;
}

.scratch-panel .close-modal {
  z-index: 20;
  top: 10px;
  right: 12px;
  color: #fff;
  background: rgba(15, 23, 42, 0.55);
}

.creation-workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  width: 100%;
  height: 100vh;
  background: #f4f7fb;
  overflow: hidden;
}

.creation-question {
  min-width: 0;
  overflow: auto;
  padding: 18px 14px 86px;
  border-right: 4px solid #66a9ff;
  background: #fff;
}

.creation-question .eyebrow {
  margin-bottom: 16px;
}

.creation-question-content,
.creation-question-content p,
.scratch-requirement {
  color: var(--ink);
  font-size: 17px;
  font-weight: 400;
  line-height: 1.55;
}

.creation-question-content h1,
.creation-question-content h2,
.creation-question-content h3 {
  color: #111827;
  font-size: 20px;
  font-weight: 500;
  line-height: 1.35;
}

.question-title,
.scratch-requirement,
.creation-question-content {
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-weight: 400;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.question-card .question-title p,
.question-card .scratch-requirement p,
.question-card .question-title div,
.question-card .scratch-requirement div,
.creation-question-content p,
.creation-question-content div,
.creation-question .scratch-requirement p,
.creation-question .scratch-requirement div {
  color: inherit;
  font-weight: inherit;
  line-height: inherit;
}

.question-title strong,
.question-title b,
.scratch-requirement strong,
.scratch-requirement b,
.creation-question-content strong,
.creation-question-content b {
  font-weight: 700;
}

.creation-question-content img,
.creation-question .scratch-requirement img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 320px;
  object-fit: contain;
  margin: 12px 0;
  border: 1px solid #d7e0ec;
  border-radius: 6px;
  background: #fff;
}

.save-work-button {
  position: sticky;
  bottom: 14px;
  width: 100%;
  margin-top: 18px;
}

.scratch-creation .scratch-editor {
  grid-template-rows: 44px 56px 1fr;
  height: 100vh;
  background: #dcecff;
}

.scratch-appbar {
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 44px;
  padding: 0 20px;
  background: #4094f7;
  color: #fff;
  font-weight: 700;
}

.scratch-appbar .save-orange {
  margin-left: auto;
  padding: 8px 28px;
  border: 0;
  border-radius: 5px;
  background: #ff8a16;
  color: #fff;
  font-weight: 800;
}

.scratch-tabs {
  display: flex;
  align-items: end;
  gap: 0;
  padding: 8px 18px 0;
  background: #dcecff;
}

.scratch-tabs button {
  min-width: 118px;
  height: 48px;
  border: 1px solid #b9c8dc;
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  background: #cbd8e8;
  color: #64748b;
  font-size: 17px;
  font-weight: 800;
}

.scratch-tabs button.active {
  background: #fff;
  color: #2f80ed;
}

.scratch-run {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  padding-bottom: 8px;
}

.scratch-body-pro {
  grid-template-columns: 230px minmax(360px, 1fr) minmax(360px, 44%);
  gap: 0;
  padding: 0;
  min-height: 0;
}

.scratch-body-pro .block-palette {
  border-radius: 0;
  border-width: 1px 1px 0 0;
  overflow: auto;
}

.block-category {
  display: block;
  margin-top: 8px;
  color: #475569;
  font-weight: 800;
}

.motion-dot::before,
.looks-dot::before,
.event-dot::before,
.control-dot::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 18px;
  margin-right: 8px;
  border-radius: 50%;
  vertical-align: -3px;
}

.motion-dot::before {
  background: #4c97ff;
}

.looks-dot::before {
  background: #9966ff;
}

.event-dot::before {
  background: #ffbf00;
}

.control-dot::before {
  background: #ffab19;
}

.scratch-body-pro .script-area {
  border-radius: 0;
  border-width: 1px 1px 0 0;
  background-image: radial-gradient(#d7dde8 1px, transparent 1px);
  background-size: 24px 24px;
}

.scratch-stage-panel {
  display: grid;
  grid-template-rows: 54px minmax(260px, 1fr) 170px;
  min-width: 0;
  border-left: 1px solid #cbd5e1;
  background: #dcecff;
}

.stage-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
}

.scratch-stage-panel .stage {
  margin: 0 12px;
  min-height: 0;
  border-radius: 8px;
  background: #fff;
}

.sprite-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(100px, 1fr));
  gap: 10px;
  padding: 12px;
  border-top: 1px solid #cbd5e1;
  background: #eef6ff;
}

.sprite-panel label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #475569;
  font-weight: 700;
}

.sprite-panel input {
  height: 36px;
  padding: 0 10px;
  border: 1px solid #d2dbe8;
  border-radius: 999px;
  text-align: center;
}

.code-creation {
  grid-template-columns: clamp(220px, 18vw, 280px) minmax(0, 1fr);
}

.code-ide {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 34%);
  gap: 12px;
  width: 100%;
  max-width: 100%;
  height: 100dvh;
  padding: 12px;
  background: #f3f4f6;
  overflow: hidden;
}

.code-main,
.code-side {
  min-width: 0;
}

.code-main {
  display: grid;
  grid-template-rows: 74px 1fr;
  border-radius: 4px;
  overflow: hidden;
  background: #292d3d;
}

.code-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 28px;
  background: #3a3e50;
}

.run-code-button {
  min-width: 104px;
  height: 48px;
  border: 0;
  border-radius: 8px;
  background: #ff8a16;
  color: #fff;
  font-size: 20px;
  font-weight: 800;
}

.language-tabs {
  display: none;
  gap: 16px;
}

.language-tabs button {
  height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: #f8fafc;
  color: #333;
  font-size: 20px;
}

.language-tabs button.active {
  background: #ef7418;
  color: #fff;
}

.code-editor-wrap,
.io-body {
  display: grid;
  grid-template-columns: 48px 1fr;
  min-height: 0;
  background: #2b2e40;
}

.line-numbers {
  padding: 12px 10px;
  background: #252838;
  color: #7b8196;
  font: 20px/1.6 Consolas, "Courier New", monospace;
  text-align: right;
  user-select: none;
}

#codeEditor,
#codeInput {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 12px;
  border: 0;
  border-radius: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: #eef2ff;
  font: 20px/1.6 Consolas, "Courier New", monospace;
}

#codeEditor::placeholder {
  color: #777d91;
}

.code-side {
  display: grid;
  grid-template-rows: 1fr 1.15fr;
  gap: 30px;
}

.io-panel {
  display: grid;
  grid-template-rows: 74px 1fr;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 4px;
  background: #2b2e40;
}

.io-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: #3a3e50;
  color: #fff;
  font-size: 22px;
  font-weight: 800;
}

.tiny-button {
  width: auto;
  padding: 8px 16px;
}

.console-body pre {
  margin: 0;
  padding: 12px;
  color: #dbeafe;
  white-space: pre-wrap;
  font: 18px/1.6 Consolas, "Courier New", monospace;
}

@media (max-width: 1180px) {
  .creation-workspace,
  .code-ide,
  .scratch-body-pro {
    grid-template-columns: 1fr;
  }

  .creation-workspace,
  .scratch-panel {
    height: auto;
    min-height: 100vh;
  }

  .code-ide,
  .scratch-creation .scratch-editor {
    height: auto;
    min-height: 760px;
  }
}

@media (max-width: 900px) {
  .code-creation {
    grid-template-columns: 1fr;
  }

  .code-side {
    grid-template-rows: minmax(220px, 1fr) minmax(260px, 1fr);
  }
}

.scratch-embed {
  display: grid;
  grid-template-rows: 1fr;
  position: relative;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  background: #dbeafe;
}

.scratch-embed-toolbar {
  display: flex;
  position: absolute;
  top: 5px;
  left: clamp(900px, 70%, 1240px);
  right: auto;
  z-index: 3;
  align-items: center;
  gap: 16px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: none;
}

.scratch-embed-toolbar strong,
.scratch-embed-toolbar span {
  display: none;
}

.scratch-embed-toolbar span {
  overflow: hidden;
  color: #64748b;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scratch-embed-toolbar button {
  min-height: 34px;
  margin-left: auto;
  padding: 0 16px;
  border-radius: 8px;
  font-size: 15px;
  white-space: nowrap;
  pointer-events: auto;
}

.scratch-embed iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  border: 0;
  background: #fff;
}

.scratch-creation {
  grid-template-columns: 320px minmax(0, 1fr);
}

@media (max-width: 1180px) {
  .scratch-embed {
    height: 760px;
  }
}
