.creator-progress .active {
  color: #a8bbff;
}

.creator-progress i {
  background: var(--line-dark);
}

.creator-controls,
.grading-controls,
.grading-result,
.question-preview,
.answer-sheet-preview {
  background: var(--surface);
}

.creator-controls {
  top: 84px;
  max-height: calc(100vh - 104px);
  overflow-y: auto;
}

.control-section {
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, .018), transparent);
}

.control-section:last-of-type {
  border-bottom: 1px solid var(--line);
}

.control-heading {
  position: relative;
  margin: 0;
  padding: 18px;
  cursor: pointer;
  list-style: none;
  transition: background .18s ease;
}

.control-heading::-webkit-details-marker {
  display: none;
}

.control-heading::marker {
  content: "";
}

.control-heading::after {
  content: "+";
  margin-inline-start: auto;
  color: #94adff;
  font: 500 18px var(--font-mono);
}

.control-section[open] > .control-heading::after {
  content: "−";
}

.control-heading:hover {
  background: rgba(79, 124, 255, .07);
}

.control-heading:focus-visible {
  outline: 2px solid #7c9cff;
  outline-offset: -3px;
}

.control-content {
  padding: 0 18px 18px;
}

.creator-actions {
  padding: 14px 18px 18px;
}

.creator-actions .generate-action {
  width: 100%;
  margin: 0;
}

.control-heading > span {
  background: linear-gradient(135deg, #4f7cff, #7c5cfc);
  color: #fff;
  box-shadow: 0 0 0 5px rgba(79, 124, 255, .12);
}

.control-heading strong {
  color: #edf1fb;
}

.creator-controls label,
.grading-controls label {
  color: #bac5dc;
}

.creator-controls input:not([type='checkbox']):not([type='radio']),
.creator-controls textarea,
.creator-controls select,
.grading-controls input:not([type='file']) {
  border-color: var(--line-dark);
  border-radius: 8px;
  background: #111722;
  color: #e8edf8;
}

.creator-controls input::placeholder,
.creator-controls textarea::placeholder,
.grading-controls input::placeholder {
  color: #687895;
}

.creator-controls input:focus,
.creator-controls textarea:focus,
.creator-controls select:focus,
.grading-controls input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(79, 124, 255, .18);
}

.creator-controls input:not([type='checkbox']):not([type='radio']):hover,
.creator-controls textarea:hover,
.creator-controls select:hover,
.grading-controls input:not([type='file']):hover {
  border-color: #526483;
  background: #141b28;
}

.creator-controls select option {
  background: #161b27;
  color: #e8edf8;
}

.creator-controls .question-source {
  border-color: var(--line-dark);
  background: #171d2a;
}

.creator-controls .question-source-info strong {
  color: #e8edf8;
}

.creator-controls .question-source-info small {
  color: #98a7c7;
}

.creator-controls .remove-question-source {
  border-color: #704451;
  background: rgba(255, 107, 129, .08);
  color: #ff9aa8;
}

.creator-controls .remove-question-source:hover {
  border-color: #a65368;
  background: rgba(255, 107, 129, .16);
}

.creator-upload,
.grading-upload {
  border-color: #536da9 !important;
  background: linear-gradient(135deg, #263d75, #342c66) !important;
  color: #f4f6ff !important;
}

.creator-upload small,
.grading-upload small {
  color: #bdc9eb;
}

.upload-mark {
  color: #a9bbff;
}

.toggle-control > span {
  border-color: #46516b;
  background: #30394c;
}

.toggle-control > span:after {
  background: #aab6d0;
}

.toggle-control input:checked + span {
  background: rgba(0, 212, 170, .42);
}

.toggle-control input:checked + span:after {
  background: #00d4aa;
}

.toggle-control strong {
  color: #e1e7f4;
}

.toggle-control small {
  color: #8998b4;
}

.creator-preview-head {
  top: 78px;
  border-color: var(--line);
  background: rgba(26, 32, 48, .94);
}

.creator-preview-head h2,
.camera-head strong,
.result-head h2 {
  color: #edf1fb;
}

.question-preview-column .question-solved-toggle {
  display: block;
  width: 100%;
  margin: 0 0 10px;
}

.creator-preview-head:before,
.camera-head:before,
.result-head:before {
  background: linear-gradient(180deg, #4f7cff, #7c5cfc);
}

.paper-stage {
  display: flex;
  min-height: 0;
  justify-content: center;
  overflow: auto;
}

.creator-paper {
  box-sizing: border-box;
  width: min(var(--paper-width, 210mm), 100%);
  min-width: 0;
  min-height: 0;
  aspect-ratio: var(--paper-ratio, 0.707);
  position: relative;
  overflow: auto;
  padding: var(--paper-margin, clamp(18px, 3vw, 36px));
}

.creator-paper.content-document.is-editing {
  min-height: 0;
}

.creator-paper .paper-empty {
  min-height: 100%;
}

.answer-sheet-document {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 18px;
}

.answer-sheet-sheet {
  flex: 0 0 auto;
  box-sizing: border-box;
  width: min(var(--answer-sheet-width, 210mm), 100%);
  height: auto;
  min-height: 0;
  aspect-ratio: var(--answer-sheet-ratio, 0.75);
  overflow: auto;
}

@media print {
  .answer-sheet-document {
    display: block;
    gap: 0;
  }

  .answer-sheet-sheet {
    width: var(--answer-sheet-width, 210mm);
    height: var(--answer-sheet-height, 280mm);
    aspect-ratio: auto;
    overflow: hidden;
  }
}

.document-toolbar[hidden],
.toolbar-panel[hidden] {
  display: none !important;
}

.column-mapping-dialog {
  width: min(680px, calc(100% - 32px));
  max-height: min(90vh, 760px);
  overflow-y: auto;
}

.column-mapping-dialog h2 {
  margin-bottom: 8px;
}

.column-mapping-file,
.column-mapping-help {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.column-mapping-file strong {
  overflow-wrap: anywhere;
  color: var(--ink);
}

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

.column-mapping-grid label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: #bdc8de;
  font-size: 12px;
}

.column-mapping-grid label small {
  color: var(--muted);
  font-size: 10px;
}

.column-mapping-grid select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-dark);
  border-radius: 8px;
  background: #111722;
  color: var(--ink);
  padding: 8px 10px;
}

.column-mapping-grid select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(79, 124, 255, .18);
  outline: 0;
}

.column-mapping-error {
  margin: 12px 0 0;
  color: #ff9aa8;
  font-size: 12px;
}

.column-mapping-error[hidden] {
  display: none;
}

.question-bank-upload-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.question-bank-upload-row .creator-upload {
  flex: 1 1 auto;
  min-width: 0;
}

.question-bank-help-open {
  display: grid;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  min-height: 36px;
  place-items: center;
  border: 1px solid #7188c4;
  border-radius: 10px;
  background: linear-gradient(145deg, #293d6a, #1d2b4d);
  color: #dce6ff;
  font-size: 21px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: background .18s ease, transform .18s ease;
}

.question-bank-help-open:hover {
  background: #354d82;
  transform: translateY(-1px);
}

.question-bank-help-open:focus-visible,
.question-bank-help-header button:focus-visible {
  outline: 3px solid #9db5ff;
  outline-offset: 3px;
}

.question-bank-help-dialog {
  width: min(860px, calc(100% - 28px));
  max-height: min(90vh, 900px);
  overflow-y: auto;
  padding: 22px;
}

.question-bank-help-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.question-bank-help-header h2 {
  margin: 4px 0 0;
}

.question-bank-help-header .eyebrow {
  color: #aab8d5;
  font-size: 11px;
}

.question-bank-help-header button {
  flex: 0 0 38px;
  width: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 23px;
}

.question-bank-help-content > p,
.question-bank-help-section > p,
.question-bank-help-section li,
.question-bank-sample figcaption {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.9;
}

.question-bank-help-section {
  margin-top: 18px;
}

.question-bank-help-section h3 {
  margin: 0 0 8px;
  color: #e4e9f4;
  font-size: 15px;
}

.question-bank-help-section ol {
  margin: 0;
  padding-inline-start: 22px;
}

.question-bank-help-content code {
  display: inline-block;
  direction: ltr;
  unicode-bidi: isolate;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  background: rgba(8, 12, 20, .5);
  padding: 0 4px;
  color: #d5e0ff;
  font-size: 11px;
}

.question-bank-sample {
  margin: 18px 0;
  overflow: hidden;
  border: 1px solid var(--line-dark);
  border-radius: 10px;
  background: #f7f9fc;
}

.question-bank-sample img {
  display: block;
  width: 100%;
  height: auto;
}

.question-bank-sample figcaption {
  padding: 4px 12px 8px;
  color: #475569;
  text-align: center;
}

.question-bank-header-aliases {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 0;
}

.question-bank-header-aliases > div {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line-dark);
  border-radius: 8px;
  background: rgba(8, 12, 20, .24);
}

.question-bank-header-aliases dt {
  margin-bottom: 5px;
  color: #e4e9f4;
  font-size: 12px;
  font-weight: 700;
}

.question-bank-header-aliases dd {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 2;
}

.question-bank-help-content .question-bank-help-limits {
  margin: 18px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line-dark);
  font-size: 12px;
}

.document-toolbar {
  position: sticky;
  bottom: 10px;
  z-index: 20;
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 12px auto;
  border: 1px solid #38445e;
  border-radius: 10px;
  background: rgba(20, 26, 39, .97);
  padding: 6px;
  box-shadow: 0 16px 46px rgba(0, 0, 0, .35);
}

.toolbar-groups,
.toolbar-control-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.document-toolbar button,
.toolbar-control-row select,
.toolbar-control-row input:not([type="range"]) {
  min-height: 36px;
  border: 1px solid #46536f;
  border-radius: 6px;
  background: #20283a;
  color: #e8edf8;
  padding: 7px 10px;
  font: inherit;
  font-size: 10px;
  cursor: pointer;
}

.document-toolbar button:hover,
.document-toolbar button.active {
  border-color: #718bd1;
  background: #2b3856;
  color: #fff;
}

.document-toolbar button:disabled {
  opacity: .48;
  cursor: not-allowed;
}

.document-toolbar button:focus-visible,
.document-toolbar select:focus-visible,
.document-toolbar input:focus-visible {
  outline: 2px solid #94adff;
  outline-offset: 2px;
}

.toolbar-group-button[aria-expanded="true"] {
  border-color: #7c95db;
  background: #33466f;
}

.document-toolbar .toolbar-save {
  border-color: #408b79;
  background: #176f5d;
  color: #fff;
}

.document-toolbar .toolbar-restore {
  border-color: #624858;
  color: #f0c3d4;
}

.toolbar-panels {
  position: absolute;
  inset-inline: 0;
  bottom: calc(100% + 10px);
  z-index: 21;
}

.toolbar-panel {
  display: grid;
  gap: 10px;
  width: min(680px, calc(100vw - 32px));
  max-height: min(48vh, 430px);
  overflow-y: auto;
  border: 1px solid #38445e;
  border-radius: 10px;
  background: rgba(20, 26, 39, .98);
  padding: 14px;
  box-shadow: 0 16px 46px rgba(0, 0, 0, .4);
}

.toolbar-panel-heading {
  display: grid;
  gap: 3px;
  color: #e8edf8;
  font-size: 11px;
}

.toolbar-panel-heading span {
  color: #9aa8c3;
  font-size: 9px;
}

.toolbar-control-row label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: #bdc8de;
  font-size: 9px;
}

.toolbar-control-row label select {
  min-width: 98px;
}

.toolbar-control-row input[type="color"] {
  width: 38px;
  height: 36px;
  padding: 4px;
}

.toolbar-control-row input[type="range"] {
  width: 100px;
  accent-color: #7c95db;
}

.toolbar-select-label select {
  min-width: 110px;
}

.clipboard-history {
  display: grid;
  max-height: 140px;
  gap: 5px;
  overflow: auto;
  border-top: 1px solid #35415a;
  padding-top: 8px;
}

.clipboard-history button {
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clipboard-history span {
  color: #9aa8c3;
  font-size: 10px;
}

.exam-inserted-image {
  display: block;
  height: auto;
  margin: 12px auto;
}

.exam-inserted-line {
  border: 0;
  border-top: 2px solid #65728a;
  margin: 14px 0;
}

.exam-inserted-shape {
  width: 90px;
  height: 54px;
  border: 2px solid #65728a;
  border-radius: 8px;
  margin: 12px auto;
}

.editor-annotation {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.editor-drawing-canvas {
  position: absolute;
  inset: 0;
  z-index: 5;
  max-width: 100%;
  touch-action: none;
  cursor: crosshair;
}

.tabs button {
  border-color: var(--line-dark);
  background: #1b2232;
  color: #bdc8de;
}

.tabs button.active {
  border-color: #4f7cff;
  background: #3c62cb;
  color: white;
}

.paper-stage {
  border-color: var(--line);
  background-color: #111722;
  background-image:
    linear-gradient(rgba(138, 155, 192, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(138, 155, 192, .045) 1px, transparent 1px);
  box-shadow: inset 0 0 80px rgba(0, 0, 0, .28);
}

.creator-paper {
  color: #17211d;
}

.paper-empty {
  color: #17211d;
}

.paper-empty p {
  color: #68716d;
}

.answer-sheet-preview > header {
  border-bottom-color: var(--line);
  background: linear-gradient(90deg, #1a2030, #20283a);
  color: #e8edf8;
}

.answer-sheet-preview > header span:last-child {
  color: #9aa8c3;
}

.creator-controls #creator-form {
  min-width: 0;
}

.creator-stepper {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 18px 14px 14px;
  list-style: none;
  border-bottom: 1px solid var(--line);
}

.creator-stepper li {
  display: grid;
  justify-items: center;
  gap: 7px;
  min-width: 0;
  color: #8793aa;
  text-align: center;
}

.creator-stepper li > span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-dark);
  border-radius: 50%;
  color: #aab5cb;
  font-size: 13px;
  transition: background .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.creator-stepper li small {
  overflow: hidden;
  width: 100%;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.creator-stepper li[aria-current="step"] {
  color: #dce5ff;
}

.creator-stepper li[aria-current="step"] > span {
  border-color: #7c9cff;
  background: #3453a7;
  box-shadow: 0 0 0 4px rgba(79, 124, 255, .16);
  color: #fff;
}

.creator-stepper li.is-complete > span {
  border-color: #498c73;
  background: #245541;
  color: #e2fff0;
}

.creator-step-panel[hidden],
.creator-review-summary[hidden],
.creator-generation-status[hidden] {
  display: none !important;
}

.creator-step-panel .control-section {
  border-bottom: 0;
}

.creator-step-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px 18px;
}

.creator-step-actions button {
  min-height: 42px;
}

.creator-step-actions button:only-child {
  margin-inline-start: auto;
}

.creator-step-actions .generate-action {
  flex: 1;
}

.creator-review {
  padding: 20px 18px 6px;
}

.creator-review h2 {
  margin: 0 0 8px;
  color: #edf1fb;
  font-size: 18px;
}

.creator-review p {
  color: #aab5cb;
  line-height: 1.7;
}

.creator-review-summary {
  display: grid;
  gap: 0;
  margin: 14px 0 0;
  border-top: 1px solid var(--line);
}

.creator-review-summary > div {
  display: grid;
  grid-template-columns: minmax(100px, .7fr) minmax(0, 1.3fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.creator-review-summary dt {
  color: #94a1ba;
}

.creator-review-summary dd {
  margin: 0;
  color: #edf1fb;
  overflow-wrap: anywhere;
}

.creator-generation-status {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 18px 0;
  padding: 12px;
  border: 1px solid rgba(124, 156, 255, .25);
  border-radius: 12px;
  background: rgba(57, 83, 153, .12);
  color: #e6edff;
}

.generation-mark {
  position: relative;
  display: grid;
  flex: 0 0 34px;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid #8eabff;
  border-radius: 50%;
}

.creator-generation-status.is-generating .generation-mark {
  animation: generation-glow 1.15s ease-in-out infinite;
}

.creator-generation-status.is-generating .generation-mark::after {
  width: 10px;
  height: 10px;
  border: 2px solid transparent;
  border-top-color: #fff;
  border-radius: 50%;
  content: "";
  animation: generation-spin .75s linear infinite;
}

.creator-generation-status.is-complete {
  border-color: rgba(64, 190, 132, .42);
  background: rgba(28, 111, 75, .2);
  color: #e8fff3;
}

.creator-generation-status.is-complete .generation-mark {
  border-color: #33b97b;
  background: #218451;
  box-shadow: 0 0 18px rgba(51, 185, 123, .34);
}

.creator-generation-status.is-complete .generation-mark::after {
  width: 8px;
  height: 14px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  content: "";
  transform: rotate(45deg) translate(-1px, -1px);
}

.new-project-dialog {
  width: min(520px, calc(100% - 28px));
}

.new-project-dialog p {
  color: #aab5cb;
  line-height: 1.7;
}

.new-project-dialog .project-dialog-actions {
  flex-wrap: wrap;
}

.new-project-dialog [hidden] {
  display: none !important;
}

@keyframes generation-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124, 156, 255, .28), 0 0 8px rgba(124, 156, 255, .35); }
  50% { box-shadow: 0 0 0 8px rgba(124, 156, 255, 0), 0 0 22px rgba(124, 156, 255, .78); }
}

@keyframes generation-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 520px) {
  .question-bank-help-dialog {
    width: calc(100% - 20px);
    padding: 16px;
  }

  .question-bank-header-aliases {
    grid-template-columns: minmax(0, 1fr);
  }

  .creator-stepper {
    gap: 2px;
    padding-inline: 8px;
  }

  .creator-stepper li small {
    font-size: 9px;
  }

  .creator-stepper li > span {
    width: 27px;
    height: 27px;
  }

  .creator-step-actions {
    flex-wrap: wrap;
    padding-inline: 12px;
  }

  .creator-step-actions button {
    flex: 1 1 120px;
  }

  .creator-review-summary > div {
    grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .creator-generation-status.is-generating .generation-mark,
  .creator-generation-status.is-generating .generation-mark::after {
    animation: none;
  }
}
