:root {
  --type-title: 24px;
  --type-body: 20px;
  --type-meta: 18px;
  --blue: #2563eb;
  --blue-2: #3b82f6;
  --teal: #4db6ac;
  --teal-dark: #3da89e;
  --teal-soft: #e8f6f4;
  --navy: #0f2942;
  --text: #1e3a5f;
  --muted: #5a7194;
  --line: #c5e6e0;
  --line-soft: #e4f5f2;
  --line-accent: #b5ddd6;
  --line-hover: #7dcfc4;
  --border-strong: var(--teal-dark);
  --bg: #ffffff;
  --good: #16a34a;
  --warn: #d97706;
  --bad: #ef4444;
  --shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
  --card-radius: 10px;
  --button-radius: 6px;
  --font-body: "Manrope", "Segoe UI", Tahoma, "Noto Sans", Arial, sans-serif;
  --fs-nav: var(--type-body);
  --fs-body: var(--type-body);
  --fs-sm: var(--type-body);
  --fs-xs: var(--type-meta);
  --artboard-w: 1600px;
  --artboard-h: 900px;
  --page-margin: 2cm;
  --scale: 1;
  --content-scale: 0.88;
}

/* Quiz page — đồng bộ scale với trang create, chỉ ẩn footer */
.quiz-create-page .layout > .footer,
.quiz-create-page .footer-compact {
  display: none;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button, a, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.viewport {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  padding: 0 var(--page-margin);
  overflow: hidden;
  background: transparent;
}

.artboard-wrap { position: relative; width: 100%; margin: 0 auto; }

.artboard {
  position: absolute;
  top: 0;
  left: 50%;
  width: var(--artboard-w);
  height: var(--artboard-h);
  min-height: var(--artboard-h);
  transform: translateX(-50%) scale(var(--scale));
  transform-origin: top center;
  overflow: visible;
}

.layout {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: var(--artboard-h);
  padding-top: var(--shell-topbar-h, 70px);
}

.layout > .topbar {
  flex: 0 0 0;
  height: 0;
  min-height: 0;
  max-height: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
  border: 0;
}

/* Main layout — rail + flat workspace */
.quiz-create-main {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 12px;
  padding: 14px;
  min-height: calc(var(--artboard-h) - 120px);
  height: calc(var(--artboard-h) - 120px);
  align-items: stretch;
}

.quiz-create-main > .config-rail,
.quiz-create-main > .quiz-workspace {
  min-width: 0;
  min-height: 0;
  height: 100%;
}

/* Rail step buttons */
.quiz-stepper {
  display: grid;
  gap: 6px;
}

.quiz-rail-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.quiz-rail-step:hover {
  background: rgba(37, 99, 235, 0.06);
}

.quiz-rail-step.is-active {
  background: rgba(37, 99, 235, 0.07);
  border-color: transparent;
  box-shadow: none;
}

.quiz-rail-step.is-done .quiz-rail-step-num {
  background: var(--good, #16a34a);
  color: #fff;
}

.quiz-rail-step.is-active:not(.is-done) .quiz-rail-step-num {
  background: var(--blue);
  color: #fff;
}

.rail-step-ready.is-done .quiz-rail-step-num {
  background: var(--good, #16a34a);
  color: #fff;
}

.quiz-rail-step-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: var(--fs-xs);
  font-weight: 800;
  background: #dbeafe;
  color: #1d4ed8;
}

.quiz-rail-step-body { min-width: 0; }

.quiz-rail-step-body strong {
  display: block;
  font-size: var(--type-body);
  font-weight: 700;
  line-height: 1.25;
}

.quiz-rail-step-body > span:last-child {
  display: block;
  margin-top: 2px;
  font-size: var(--type-meta);
  opacity: 0.85;
  line-height: 1.35;
}

.rail-summary dt {
  margin: 0;
  opacity: 0.85;
}

.rail-summary dd {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.rail-actions .btn-open {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--blue);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.2);
}

.rail-actions .btn-open:disabled,
.rail-actions .btn-open.is-disabled {
  opacity: 1;
  background: #e8eef7;
  color: #94a3b8;
  box-shadow: none;
}

.rail-actions .rail-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.rail-upload-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  width: 100%;
}

.rail-upload-stack > button {
  width: 100%;
}

.rail-sample-link {
  font-size: var(--type-body);
  font-weight: 600;
  color: var(--muted, #5b6f88);
  text-decoration: underline;
  text-underline-offset: 2px;
  line-height: 1.3;
}

.rail-sample-link:hover {
  color: var(--blue);
}

/* Soft workspace shell on white canvas */
.quiz-workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: calc(var(--artboard-h) - 160px);
  background: rgba(255, 255, 255, 0.34);
  backdrop-filter: blur(20px) saturate(1.12);
  -webkit-backdrop-filter: blur(20px) saturate(1.12);
  border: 1px solid rgba(47, 107, 255, 0.14);
  border-radius: 16px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.55) inset, 0 10px 28px rgba(21, 42, 69, 0.06);
  overflow: hidden;
}

.quiz-workspace-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(21, 42, 69, 0.07);
  background: transparent;
  flex-shrink: 0;
}

.quiz-workspace-title {
  font-weight: 700;
  color: var(--navy);
  font-size: var(--fs-sm);
}

.quiz-workspace-util {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quiz-workspace-util .btn-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 4px;
  border: none;
  background: none;
  color: var(--blue);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.quiz-workspace-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.quiz-workspace-panel[hidden] {
  display: none !important;
}

.quiz-workspace-panel.game-brief-editor {
  padding: 18px 20px 22px;
}

/* Legacy folder shell — kept for any stray refs */
.quiz-folder-shell {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: calc(var(--artboard-h) - 160px);
}

.quiz-folder-header {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.quiz-header-row-main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-width: 0;
}

.main-folder-tabs {
  flex: 1;
  min-width: 0;
}

.quiz-header-actions .btn-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.folder-tab {
  position: relative;
  padding: 11px 22px;
  border: 1px solid var(--line-accent);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  background: #eef4fc;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.2;
  margin-bottom: -1px;
  z-index: 1;
}

.folder-tab:hover {
  background: #f5f9ff;
  color: var(--text);
}

.folder-tab.is-active {
  background: #fff;
  color: var(--blue);
  border-color: var(--line-accent);
  z-index: 3;
  box-shadow: 0 -2px 8px rgba(77, 182, 172, 0.12);
}

.folder-tab.has-error:not(.is-active) {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.folder-tab.is-valid:not(.is-active) {
  background: #f0fdf4;
  color: #15803d;
  border-color: #bbf7d0;
}

.folder-tab.folder-tab-q.is-valid.is-active {
  background: #fff;
  color: var(--good);
  border-color: #86efac;
}

.folder-tab.folder-tab-q.has-error.is-active {
  background: #fff;
  color: var(--bad);
  border-color: #fca5a5;
}

.folder-tab-bar {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  flex-wrap: wrap;
  min-width: 0;
}

.quiz-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-sm {
  padding: 10px 16px !important;
  font-size: var(--fs-xs) !important;
  border-radius: var(--button-radius) !important;
}

.quiz-folder-body {
  position: relative;
  z-index: 2;
  flex: 1;
  min-height: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 0 14px 14px 14px;
  background: #fff;
  box-shadow: var(--shadow);
}

.quiz-folder-body .quiz-panel {
  padding: 16px 18px 20px;
  min-height: calc(var(--artboard-h) - 280px);
}

.quiz-folder-body .quiz-panel[hidden] {
  display: none !important;
}

/* Question sub-tabs */
.question-tabs-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 18px 0;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 0;
  min-width: 0;
  flex-shrink: 0;
}

.question-folder-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  min-width: 0;
  flex: 1;
}

.question-folder-tabs .folder-tab.folder-tab-q {
  position: relative;
  padding: 8px 16px;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 6px 6px 0 0;
  margin-bottom: -1px;
  background: none;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 700;
  box-shadow: none;
  z-index: 1;
  cursor: pointer;
}

.question-folder-tabs .folder-tab.folder-tab-q:hover {
  color: var(--text);
  background: #f8fafc;
}

.question-folder-tabs .folder-tab.folder-tab-q.is-active {
  color: var(--blue);
  border-bottom-color: var(--blue);
  background: #fff;
  box-shadow: none;
}

.question-folder-tabs .folder-tab.folder-tab-q.is-valid:not(.is-active) {
  color: var(--good);
  background: transparent;
  border-color: transparent;
}

.question-folder-tabs .folder-tab.folder-tab-q.has-error:not(.is-active) {
  color: var(--bad);
  background: #fef2f2;
  border-color: transparent;
}

.question-folder-tabs .folder-tab.folder-tab-q.is-valid.is-active {
  color: var(--good);
  border-bottom-color: var(--good);
}

.question-folder-tabs .folder-tab.folder-tab-q.has-error.is-active {
  color: var(--bad);
  border-bottom-color: var(--bad);
}

.question-folder-tabs .folder-tab.folder-tab-add {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px dashed #b8cce8;
  border-radius: 6px;
  margin-bottom: 6px;
  background: #fff;
  color: var(--blue);
  font-size: var(--type-body);
  font-weight: 800;
  line-height: 1;
  flex-shrink: 0;
}

.question-folder-tabs .folder-tab.folder-tab-add:hover {
  border-color: var(--blue);
  background: #eff6ff;
}

.q-illus-alt-label {
  display: block;
  margin-top: 8px;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--muted);
}

.q-illus-alt {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 6px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  font: inherit;
  font-size: var(--fs-xs);
}

.import-summary-line {
  margin: 4px 0 0;
  font-size: var(--fs-xs);
}

.qc-modal-sheet-wide {
  max-width: min(96vw, 920px);
  width: 100%;
}

.generate-modal-status {
  margin: 0 0 10px;
  font-size: var(--fs-sm);
  font-weight: 700;
}

.generate-modal-meta {
  margin: 0 0 10px;
  font-size: var(--fs-xs);
  color: var(--muted);
}

.generate-intro {
  margin: 0 0 12px;
  font-size: var(--fs-sm);
  color: var(--muted);
}

.generate-summary {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: #f8fafc;
}

.generate-summary-row {
  display: grid;
  grid-template-columns: minmax(120px, 38%) 1fr;
  gap: 8px 12px;
  padding: 6px 0;
}

.generate-summary-row + .generate-summary-row {
  border-top: 1px solid var(--line-soft);
}

.generate-summary dt {
  margin: 0;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--muted);
}

.generate-summary dd {
  margin: 0;
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ink);
}

.generate-section-label {
  margin: 0 0 8px;
  font-size: var(--fs-xs);
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.generate-model-hint,
.generate-progress-meta {
  margin: 10px 0 0;
  font-size: var(--fs-xs);
  color: var(--muted);
}

.model-picker {
  position: relative;
  margin-top: 4px;
}

.model-picker-budget-hint {
  display: block;
  margin-top: 6px;
  font-size: var(--fs-xs);
  color: var(--warn, #b45309);
}

.model-picker-budget-hint[hidden] {
  display: none !important;
}

.model-picker-trigger {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  height: auto;
  min-height: 44px;
  max-height: none;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1.5px solid var(--line-soft);
  border-radius: 12px;
  background: #fff;
  font-size: var(--type-meta);
  font-weight: 600;
  line-height: 1.3;
  color: var(--navy, var(--ink));
  cursor: pointer;
  text-align: left;
  white-space: normal;
  overflow: visible;
}

.model-picker-trigger:hover {
  border-color: #cfe0ff;
  background: #f5f9ff;
}

.model-picker-trigger.is-disabled,
.model-picker-trigger:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.model-picker-trigger .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok, #16a34a);
  flex-shrink: 0;
}

.model-picker-trigger .dot.is-warn {
  background: var(--warn, #b45309);
}

.model-picker-trigger-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
  line-height: 1.3;
}

.model-picker-caret {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  display: block;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.55;
}

.model-picker-menu {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  overflow-x: hidden;
  overflow-y: auto;
  box-sizing: border-box;
  --model-option-height: 52px;
  --model-picker-visible-rows: 4;
  max-height: calc(var(--model-option-height) * var(--model-picker-visible-rows) + 12px);
  padding: 6px;
}

.model-picker-menu.is-floating {
  position: fixed;
  right: auto !important;
  top: auto;
  overflow-x: hidden;
  max-width: min(100vw - 24px, 420px);
}

.model-picker-menu[hidden] {
  display: none !important;
}

.model-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  min-width: 0;
  min-height: var(--model-option-height);
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
  white-space: normal;
}

.model-option:hover {
  background: #f1f5f9;
}

.model-option.is-selected {
  background: var(--accent-soft, #eef5ff);
}

.model-option.is-off {
  opacity: 0.65;
}

.model-option strong {
  font-size: inherit;
  font-weight: 700;
  color: var(--ink, var(--navy));
  line-height: 1.3;
  max-width: 100%;
  overflow-wrap: break-word;
}

.model-option span {
  font-size: 0.875em;
  color: var(--muted);
  line-height: 1.3;
  max-width: 100%;
  overflow-wrap: break-word;
}

.generate-progress-panel {
  margin-bottom: 4px;
}

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

.btn-open {
  padding: 10px 16px;
  border: none;
  border-radius: var(--button-radius, 10px);
  background: #eef5ff;
  color: var(--accent, #2563eb);
  font-size: var(--fs-sm);
  font-weight: 700;
  cursor: pointer;
}

.btn-open:disabled,
.btn-open.is-disabled {
  pointer-events: none;
  opacity: 0.45;
  background: #f1f5f9;
  color: var(--muted);
  cursor: not-allowed;
}

.progress-card {
  padding: 14px 18px;
  border: 1px solid #cfe0ff;
  border-radius: var(--card-radius, 12px);
  background: #fff;
  box-shadow: var(--shadow, 0 8px 24px rgba(15, 23, 42, 0.06));
}

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

.progress-top strong {
  font-size: var(--fs-sm);
  color: var(--ink);
}

.progress-top strong.is-running { color: var(--accent); }
.progress-top strong.is-success { color: #15803d; }
.progress-top strong.is-error { color: #dc2626; }
.progress-top strong.is-warn { color: #ca8a04; }

.progress-metrics {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-size: var(--fs-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: #e8eef8;
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.25s linear;
}

.generate-preview-wrap {
  margin: 12px 0;
  border: 1.5px solid #334155;
  border-radius: 12px;
  overflow: hidden;
  background: #0f172a;
  aspect-ratio: 16 / 9;
  max-height: 52vh;
}

.generate-preview-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #0f172a;
}

.question-folder-tabs {
  flex: 1;
  min-width: 0;
  flex-shrink: 0;
  margin-bottom: 0;
}

.q-tab-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  font-size: var(--fs-xs);
  color: var(--muted);
  padding-bottom: 8px;
}

.q-tab-meta label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  white-space: nowrap;
}

.q-tab-meta input {
  width: 68px;
  padding: 7px 8px;
  font-size: var(--fs-xs);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
}

.q-tab-meta input:disabled {
  background: #f1f5f9;
  color: var(--muted);
  cursor: not-allowed;
}

.q-tab-meta .q-delete {
  padding: 7px 12px;
  font-size: var(--fs-xs);
  font-weight: 700;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff;
  color: var(--bad);
  white-space: nowrap;
}

.folder-tab.folder-tab-q {
  padding: 9px 16px;
  font-size: var(--fs-xs);
  border-radius: 9px 9px 0 0;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: grab;
  touch-action: none;
  user-select: none;
  border: 1.5px solid var(--line-hover);
  background: #f8fafc;
  color: var(--navy);
  font-weight: 700;
  font-family: inherit;
}

.folder-tab.folder-tab-q:active {
  cursor: grabbing;
}

.folder-tab.folder-tab-add {
  width: 40px;
  padding: 9px 0;
  text-align: center;
  font-size: var(--type-title);
  font-weight: 800;
  line-height: 1;
  color: var(--blue);
  flex-shrink: 0;
}

.question-editor-host {
  flex: 1;
  min-height: 0;
  background: transparent;
  padding: 16px 18px 20px;
  margin-top: 0;
  border: none;
  border-radius: 0;
}

.score-settings-strip,
.score-settings-inline {
  flex-shrink: 0;
  margin: 0;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  font-size: var(--fs-xs);
}

.score-strip {
  display: flex;
  align-items: center;
  gap: 10px 14px;
  flex-wrap: wrap;
}

.score-strip-title {
  font-size: var(--fs-sm);
  font-weight: 800;
  color: var(--navy);
  white-space: nowrap;
}

.score-mode-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.score-mode-label.is-active {
  color: var(--blue);
}

.score-mode-switch {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  cursor: pointer;
}

.score-mode-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.score-mode-switch-ui {
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  position: relative;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.score-mode-switch-ui::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 41, 66, 0.18);
  transition: transform 0.2s ease;
}

.score-mode-switch input:checked + .score-mode-switch-ui {
  background: var(--blue);
  border-color: var(--blue);
}

.score-mode-switch input:checked + .score-mode-switch-ui::after {
  transform: translateX(18px);
}

.score-mode-switch input:focus-visible + .score-mode-switch-ui {
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.score-strip-fields {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.score-strip-fields label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.score-strip-fields input {
  width: 72px;
  padding: 7px 8px;
  font-size: var(--fs-xs);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
}

.score-strip-hint {
  font-size: var(--type-meta);
  color: var(--muted);
  white-space: nowrap;
}

.score-strip label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.score-strip input,
.score-strip select {
  width: 80px;
  padding: 8px 10px;
  font-size: var(--fs-xs);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.score-strip input:disabled {
  background: #f1f5f9;
  color: var(--muted);
  cursor: not-allowed;
}

.score-mode-toggle.compact {
  display: inline-flex;
  gap: 4px;
}

.score-mode-toggle.compact .score-mode-btn {
  padding: 8px 14px;
  font-size: var(--fs-xs);
}

.config-rail {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  max-height: none;
  padding: 16px 14px;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.34);
  backdrop-filter: blur(20px) saturate(1.12);
  -webkit-backdrop-filter: blur(20px) saturate(1.12);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.55) inset, 0 10px 28px rgba(21, 42, 69, 0.06);
  color: var(--navy, #152a45);
  border: 1px solid rgba(47, 107, 255, 0.14);
}

.config-rail::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.55) 0%, transparent 42%),
    linear-gradient(90deg, rgba(37, 99, 235, 0.06), transparent 50%);
  pointer-events: none;
}

.config-rail > * { position: relative; z-index: 1; }

.config-rail h2 {
  margin: 0;
  font-size: clamp(1.35rem, 1.15rem + 0.55vw, 1.7rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--navy, #152a45);
}

.quiz-rail-head {
  flex-shrink: 0;
  margin-bottom: 2px;
}

.config-rail .lead {
  margin: 0;
  color: var(--muted, #5b6f88);
  font-size: var(--fs-sm);
  line-height: 1.4;
}

.quiz-stepper {
  display: grid;
  gap: 8px;
}

.quiz-step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.quiz-step-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: var(--fs-xs);
  font-weight: 800;
  background: rgba(255, 255, 255, 0.25);
}

.quiz-step-item.is-active .quiz-step-num { background: #fff; color: var(--blue); }
.quiz-step-item.is-done .quiz-step-num { background: var(--good); color: #fff; }
.quiz-step-item.is-warn .quiz-step-num { background: var(--warn); color: #fff; }

.quiz-step-body { min-width: 0; flex: 1; }
.quiz-step-body strong { display: block; font-size: var(--fs-xs); }
.quiz-step-body span { display: block; margin-top: 2px; font-size: var(--type-body); opacity: 0.85; }

.rail-summary {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.3);
  font-size: var(--fs-xs);
}

.rail-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.rail-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.rail-progress-slot {
  flex: 0 0 118px;
  min-height: 118px;
  max-height: 118px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow: hidden;
}

.rail-progress-block {
  display: grid;
  grid-template-rows: 8px auto minmax(1.3em, 1.3em) minmax(1.25em, 1.25em);
  gap: 6px;
  width: 100%;
  min-height: 118px;
  box-sizing: border-box;
}

/* Keep layout space even when idle — avoid jump / overlap */
.rail-progress-block[hidden] {
  display: grid !important;
  visibility: hidden;
  pointer-events: none;
}

.rail-progress-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 1.2em;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--muted, #5b6f88);
  line-height: 1.2;
}

#generate-progress-percent {
  color: var(--navy, var(--ink));
  min-width: 2.8em;
  text-align: left;
}

#generate-progress-elapsed {
  color: var(--blue, var(--accent));
  min-width: 3.2em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#generate-progress-elapsed.is-running {
  color: var(--blue, var(--accent));
}

.rail-progress-detail {
  margin: 0;
  min-height: 1.3em;
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.3;
  color: var(--muted, #5b6f88);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-progress-detail.is-running { color: var(--blue, #2563eb); }
.rail-progress-detail.is-success { color: #15803d; }
.rail-progress-detail.is-error { color: #b91c1c; }

.rail-progress-cost {
  margin: 0;
  min-height: 1.25em;
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1.25;
  color: #15803d;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-progress-cost.is-empty,
.rail-progress-cost:empty {
  visibility: hidden;
}

.rail-progress-cost[hidden] {
  display: block !important;
  visibility: hidden;
}

.rail-btn-primary.is-cancel-mode {
  background: #fff7ed !important;
  color: #9a3412 !important;
  border-color: #fdba74 !important;
  box-shadow: none !important;
}

.rail-btn-primary.is-cancel-mode:hover:not(:disabled) {
  background: #ffedd5 !important;
  color: #9a3412 !important;
}

.rail-step-ready {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--navy, #152a45);
  font: inherit;
  font-size: inherit;
  font-weight: 700;
  text-align: left;
  box-sizing: border-box;
}

.rail-step-ready .quiz-rail-step-num {
  width: 26px;
  height: 26px;
  margin-top: 0;
}

.rail-step-ready-label {
  display: block;
  min-width: 0;
  font-size: var(--type-body, var(--fs-body, 20px));
  font-weight: 700;
  line-height: 1.25;
  color: inherit;
}

.rail-step-ready.is-disabled {
  opacity: 0.55;
}

.rail-actions button {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid #d5e4f7;
  background: #fff;
  color: var(--navy, #152a45);
  font-size: var(--fs-xs);
  font-weight: 700;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.rail-actions button:hover {
  background: #eef4ff;
  border-color: #93c5fd;
  color: var(--blue);
}

.rail-actions button.rail-btn-primary {
  background: var(--blue);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.2);
}

.rail-actions button.rail-btn-primary:hover:not(:disabled) {
  background: #1d4ed8;
  color: #fff;
}

/* Workspace */
.quiz-workspace-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: 0;
}

.progress-card {
  padding: 14px 18px;
  border: 1px solid var(--line-accent);
  border-radius: var(--card-radius);
  background: #fff;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

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

.progress-top strong { font-size: var(--fs-sm); }
.progress-top strong.is-ok { color: var(--good); }
.progress-top strong.is-warn { color: var(--warn); }
.progress-top strong.is-bad { color: var(--bad); }

.validation-metrics {
  display: inline-flex;
  gap: 14px;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--muted);
}

.validation-metrics .err-count { color: var(--bad); }
.validation-metrics .warn-count { color: var(--warn); }

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

/* Cards — feature surfaces on seamless page */
.qc-card {
  border: 1px solid rgba(47, 107, 255, 0.14);
  border-radius: 14px;
  background: var(--edu-feature-box-grad, linear-gradient(145deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 251, 255, 0.92) 52%, rgba(236, 244, 255, 0.78) 100%));
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.65) inset,
    0 0 0 1px rgba(255, 122, 61, 0.06),
    0 8px 22px rgba(15, 41, 66, 0.07);
}

.qc-card h3 {
  margin: 0 0 12px;
  font-size: var(--fs-sm);
  color: var(--navy);
  font-weight: 800;
}

.import-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.import-actions button {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8fbff;
  color: var(--text);
  font-size: var(--fs-xs);
  font-weight: 700;
}

.import-actions button:hover {
  border-color: var(--teal);
  background: #eff6ff;
}

/* Score settings */
.score-mode-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.score-mode-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8fbff;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--muted);
}

.score-mode-btn.is-active {
  border-color: var(--blue);
  background: #eff6ff;
  color: var(--blue);
}

.score-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.score-fields label {
  display: grid;
  gap: 6px;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--muted);
}

.score-fields input,
.score-fields select {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbff;
  font-size: var(--fs-xs);
}

.score-hint {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f0f7ff;
  font-size: var(--fs-xs);
  color: var(--muted);
}

.score-hint.is-warn {
  background: #fffbeb;
  color: #92400e;
}

/* Question cards */
.question-pack-editor { display: grid; gap: 10px; }

.q-card {
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: var(--panel, #fafcff);
  overflow: hidden;
  transition: box-shadow 0.15s ease;
}

.q-card.is-dragging { opacity: 0.5; }
.q-card.is-drop-target { box-shadow: 0 0 0 2px var(--blue); }

.q-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #fff;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}

.q-drag-handle {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: var(--type-meta);
  cursor: grab;
  display: grid;
  place-items: center;
}

.q-drag-handle:active { cursor: grabbing; }

.q-order-input {
  width: 48px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: center;
  font-size: var(--fs-xs);
  font-weight: 700;
}

.q-card-title {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.q-badge {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: var(--type-body);
  font-weight: 700;
}

.q-badge.ok { background: #dcfce7; color: var(--good); }
.q-badge.warn { background: #fef3c7; color: var(--warn); }
.q-badge.bad { background: #fee2e2; color: var(--bad); }

.q-head-points {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--type-body);
  color: var(--muted);
}

.q-head-points input {
  width: 56px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: var(--type-body);
  text-align: center;
}

.q-head-points input:disabled {
  opacity: 0.6;
  background: #f1f5f9;
}

.q-card-actions {
  display: flex;
  gap: 6px;
}

.q-card-actions button {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel, #fff);
  font-size: var(--type-body);
  font-weight: 700;
  color: var(--muted);
}

.q-card-actions button.q-delete:hover {
  border-color: #fca5a5;
  color: var(--bad);
  background: #fef2f2;
}

.q-card-body {
  padding: 14px 16px;
  display: grid;
  gap: 14px;
}

.q-card-body[hidden] { display: none !important; }

.q-field label {
  display: block;
  margin-bottom: 6px;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--muted);
}

.q-field textarea,
.q-field input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(47, 107, 255, 0.22);
  border-radius: 10px;
  background: #fff;
  font-size: var(--fs-xs);
  line-height: 1.45;
  resize: vertical;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 1),
    0 1px 0 rgba(222, 233, 248, 0.98),
    0 2px 0 rgba(208, 222, 242, 0.62),
    0 3px 6px rgba(15, 41, 66, 0.05),
    0 8px 20px rgba(15, 41, 66, 0.08);
}

.q-image-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.q-image-preview {
  width: 80px;
  height: 60px;
  border-radius: 8px;
  border: 1px solid var(--line);
  object-fit: cover;
  background: #f1f5f9;
}

.q-option-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto auto auto auto;
  gap: 8px;
  align-items: start;
  padding: 10px 12px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid rgba(47, 107, 255, 0.16);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 1),
    0 1px 0 rgba(222, 233, 248, 0.9),
    0 3px 10px rgba(15, 41, 66, 0.06);
}

.q-option-row[data-list="classifyItems"],
.q-option-row.q-classify-row {
  grid-template-columns: 32px minmax(0, 1fr) auto minmax(100px, 128px) auto;
  align-items: center;
}

.q-option-row.q-classify-row:not(.has-attachment) .opt-content {
  flex-direction: row;
  align-items: center;
}

.q-option-row.q-classify-row .classify-cat {
  align-self: center;
  max-width: 128px;
}

.q-option-row[data-list="orderItems"],
.q-option-row.q-order-row {
  grid-template-columns: 32px minmax(0, 1fr) auto auto auto;
  align-items: center;
}

.q-option-row.q-order-row:not(.has-attachment) .opt-content {
  flex-direction: row;
  align-items: center;
}

.q-option-row.q-order-row .opt-order-btns {
  align-self: center;
}

.q-option-row.q-order-row .opt-delete {
  align-self: center;
}

.opt-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.opt-content input[type="text"] {
  width: 100%;
}

.btn-opt-image,
.btn-opt-attach {
  align-self: start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel, #f8fbff);
  color: var(--text);
  cursor: pointer;
}

.q-option-row .btn-opt-attach--answer {
  width: auto;
  min-width: 148px;
  height: 38px;
  padding: 8px 12px;
  gap: 6px;
  justify-content: flex-start;
  font-size: var(--fs-xs);
  font-weight: 700;
  white-space: nowrap;
}

.q-option-row .btn-opt-attach--answer:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: var(--line);
  color: var(--muted);
}

.btn-opt-attach-label {
  line-height: 1;
}

.btn-opt-image:hover,
.btn-opt-attach:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.btn-opt-attach svg {
  width: 18px;
  height: 18px;
}

.opt-image-preview,
.opt-attach-preview {
  position: relative;
  width: 72px;
  height: 54px;
  border-radius: 8px;
  border: 1.5px solid var(--border-strong);
  background: #fff;
  overflow: hidden;
}

.opt-image-preview img,
.opt-attach-preview--image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.opt-attach-preview--audio {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  max-width: 100%;
}

.opt-attach-preview--audio audio {
  height: 32px;
  max-width: 220px;
}

.opt-attach-name {
  font-size: var(--fs-xs);
  color: var(--muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opt-image-clear,
.opt-attach-clear {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: var(--type-meta);
  line-height: 1;
  cursor: pointer;
}

.opt-order-btns {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.opt-order-btns .btn-ghost {
  padding: 2px 8px;
  min-width: 32px;
}

.opt-correct-spacer {
  width: 52px;
}

.classify-cat {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: var(--fs-xs);
  background: #fff;
}

.q-tf-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.q-tf-opt {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--navy);
}

.q-cat-list,
.q-label-list,
.q-label-points,
.q-hotspot-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.q-cat-row,
.q-label-row,
.q-label-point-row,
.q-hotspot-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.q-cat-row input,
.q-label-row input {
  flex: 1;
  min-width: 120px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: var(--fs-xs);
}

.q-label-point-row select,
.q-label-point-row input,
.q-hotspot-row input {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: var(--fs-xs);
}

.q-label-point-row label,
.q-hotspot-row label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-xs);
  color: var(--muted);
  font-weight: 700;
}

.q-label-point-row input,
.q-hotspot-row input {
  width: 56px;
}

.q-hotspot-row .hs-correct {
  font-size: var(--fs-xs);
  color: var(--navy);
}

.q-sub-label {
  margin-top: 8px;
}

.q-answer-warn {
  color: #b45309;
}

.q-classify-list {
  margin-top: 4px;
}

.q-problem-attach-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.q-problem-attach-row .opt-attach-preview {
  flex: 1 1 100%;
}

.attach-limit-hint,
.q-problem-audio-hint {
  font-size: var(--fs-xs);
  color: var(--muted);
  line-height: 1.3;
}

.qc-attach-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30000;
  max-width: min(92vw, 480px);
  padding: 12px 16px;
  border-radius: 10px;
  background: #7f1d1d;
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1.4;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
}

.qc-attach-toast[hidden] {
  display: none !important;
}

.q-option-label {
  font-weight: 800;
  color: var(--blue);
  text-align: center;
}

.q-option-row input[type="text"] {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: var(--fs-xs);
  background: #fff;
  color: var(--text, #1e3a5f);
}

.q-option-row .opt-correct {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--type-body);
  color: var(--muted);
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  padding: 48px 24px 40px;
  border: none;
  border-radius: 0;
  background: transparent;
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: var(--type-body);
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -0.02em;
}

.empty-state p {
  margin: 0 0 20px;
  font-size: var(--fs-sm);
  color: var(--muted);
  line-height: 1.5;
  max-width: 40ch;
  margin-left: auto;
  margin-right: auto;
}

.empty-state span {
  font-size: var(--fs-xs);
  color: var(--muted);
  line-height: 1.5;
}

/* Game brief */
.game-brief-editor .qc-card { margin-bottom: 16px; }

.style-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.style-chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f8fbff;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--muted);
}

.style-chip.is-selected {
  border-color: var(--blue);
  background: #eff6ff;
  color: var(--blue);
}

.color-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}

.color-swatch.is-selected {
  border-color: var(--navy);
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--navy);
}

.brief-preview-card {
  padding: 16px;
  border-radius: var(--card-radius);
  border: 1px solid var(--line);
  background: linear-gradient(135deg, #f8fbff 0%, #eef5ff 100%);
  font-size: var(--fs-xs);
  line-height: 1.6;
}

.brief-preview-card.has-accent {
  border-left: 4px solid var(--brief-accent, var(--blue));
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.suggestion-chip {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: var(--type-body);
  color: var(--blue);
  font-weight: 600;
  text-align: left;
}

.suggestion-chip:hover { background: #eff6ff; }

/* Workspace footer actions */
.workspace-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 18px;
  border-top: 1px solid var(--line-soft);
  background: #fafcff;
  flex-shrink: 0;
}

.btn-primary {
  padding: 10px 18px;
  border: none;
  border-radius: var(--button-radius);
  background: var(--blue);
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: 700;
  box-shadow: 0 10px 20px rgba(18, 96, 255, 0.22);
}

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

.btn-ghost {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--button-radius);
  background: #fff;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 700;
}

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

/* Import preview */
.import-preview-card {
  margin: 0;
  padding: 10px 18px;
  border-radius: 0;
  background: #f0f7ff;
  border: none;
  border-bottom: 1px solid var(--line-accent);
  font-size: var(--fs-xs);
  flex-shrink: 0;
}

/* Modals */
.qc-modal[hidden] { display: none !important; }

.qc-modal {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: grid;
  place-items: center;
  padding: 16px;
}

.qc-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}

.qc-modal-sheet {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: min(92vh, 860px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  overflow: hidden;
}

.qc-modal-sheet.wide { width: min(920px, 100%); }

.qc-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.qc-modal-head h2 {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--navy);
}

.qc-modal-close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.qc-modal-body {
  padding: 14px 16px 16px;
  overflow: auto;
  min-height: 0;
}

.qc-modal-body textarea {
  width: 100%;
  min-height: 280px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f9fbff;
  font-size: var(--fs-xs);
  line-height: 1.5;
  resize: vertical;
}

.qc-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.ocr-drop-zone {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 32px 20px;
  text-align: center;
  background: #f8fbff;
  cursor: pointer;
}

.ocr-drop-zone.is-dragover {
  border-color: var(--blue);
  background: #eff6ff;
}

.ocr-preview-img {
  max-width: 100%;
  max-height: 280px;
  border-radius: 10px;
  margin-top: 12px;
}

.ocr-result-text {
  width: 100%;
  min-height: 120px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f9fbff;
  font-size: var(--fs-xs);
}

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

.draft-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbff;
}

.draft-item-info { min-width: 0; flex: 1; }
.draft-item-info strong { display: block; font-size: var(--fs-xs); }
.draft-item-info span { font-size: var(--type-body); color: var(--muted); }

.draft-item-actions { display: flex; gap: 6px; flex-shrink: 0; }

.draft-item-actions button {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: var(--type-body);
  font-weight: 700;
}

.footer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 0 28px;
  min-height: 50px;
  border-top: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.86);
  color: var(--muted);
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.footer-brand .brand-mark {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  font-size: var(--type-body);
}

.footer-left p {
  margin: 0;
  font-size: var(--type-body);
  white-space: nowrap;
}

.footer-center {
  display: flex;
  justify-content: center;
  gap: 18px;
  font-size: var(--type-body);
}

.footer-right { font-size: var(--type-body); white-space: nowrap; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.q-field textarea.is-invalid,
.q-field input.is-invalid,
.q-option-row input.is-invalid {
  border-color: var(--bad);
  background: #fff5f5;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.12);
}

.q-field label.is-invalid-label {
  color: var(--bad);
}

.q-image-crop-frame {
  width: 100%;
  max-width: 560px;
  height: 280px;
  margin: 0 auto;
  background: #0f172a;
  border-radius: 12px;
  overflow: hidden;
}

.q-image-crop-frame img {
  display: block;
  max-width: 100%;
}

.q-image-crop-frame .cropper-container {
  width: 100% !important;
  height: 280px !important;
}

.q-question-image-frame {
  width: 100%;
  max-width: 360px;
  height: 200px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f1f5f9;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.q-question-image-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.q-question-image-frame.is-empty {
  border-style: dashed;
  color: var(--muted);
  font-size: var(--fs-xs);
}

.crop-hint {
  margin: 0 0 10px;
  font-size: var(--fs-xs);
  color: var(--muted);
}

.ocr-crop-frame { margin-top: 12px; }

.ocr-status-line {
  margin-top: 10px;
  font-size: var(--fs-xs);
  color: var(--muted);
}

.sample-dropdown {
  position: relative;
  display: inline-block;
}

.sample-dropdown-trigger {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--blue);
  font-size: var(--fs-xs);
  font-weight: 700;
}

.sample-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
}

.sample-dropdown-menu[hidden] { display: none !important; }

.sample-dropdown-menu a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text);
}

.sample-dropdown-menu a:hover {
  background: #eff6ff;
  color: var(--blue);
}

@media (max-width: 1100px) {
  .quiz-create-main {
    grid-template-columns: 1fr;
    padding: 14px;
    height: auto;
    min-height: 0;
  }

  .config-rail {
    max-height: none;
    height: auto;
  }

  .rail-progress-slot {
    flex-basis: auto;
    min-height: 118px;
    max-height: none;
  }

  .q-input-split,
  .q-interaction-split { flex-direction: column; }
  .q-illus-panel,
  .q-interaction-panel-side { width: 100%; max-width: 100%; flex: 1 1 auto; }
  .score-strip-fields { margin-left: 0; width: 100%; }
}

/* —— Question editor (đồng bộ create page) —— */
.question-editor-host .q-card {
  border: none;
  background: transparent;
  box-shadow: none;
  margin: 0;
  padding: 0;
}

html[data-theme="dark"] .question-editor-host {
  background: transparent !important;
}

html[data-theme="dark"] .score-settings-strip,
html[data-theme="dark"] .score-settings-inline {
  background: transparent !important;
  border-bottom-color: rgba(147, 197, 253, 0.16) !important;
}

html[data-theme="dark"] .question-tabs-toolbar {
  border-bottom-color: rgba(147, 197, 253, 0.16) !important;
}

.question-editor-host .q-card-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0;
}

.q-compact-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: var(--fs-xs);
  color: var(--muted);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line-soft);
}

.q-compact-meta label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.q-compact-meta input {
  width: 72px;
  padding: 8px 10px;
  font-size: var(--fs-xs);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
}

.q-compact-meta .q-delete {
  margin-left: auto;
  padding: 8px 14px;
  font-size: var(--fs-xs);
  font-weight: 700;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff;
  color: var(--bad);
}

/* 2 cột: đề bài + minh họa */
.q-input-split {
  display: flex;
  align-items: stretch;
  gap: 14px;
}

.q-problem-panel {
  flex: 1;
  min-width: 0;
}

.q-illus-panel {
  flex: 0 0 34%;
  width: 34%;
  min-width: 180px;
  max-width: 34%;
}

.q-input-panel,
.input-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  min-height: 0;
  min-width: 0;
}

.q-input-panel.q-illus-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.q-panel-head,
.input-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.q-panel-head > span,
.input-panel-head > span {
  color: var(--navy);
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.02em;
}

.req-mark {
  color: var(--bad);
  font-weight: 800;
}

.q-answer-editor > label .req-mark,
.brief-field > span .req-mark {
  margin-left: 1px;
}

.q-problem-panel,
.q-illus-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 10px 12px;
  border: 1px solid rgba(47, 107, 255, 0.14);
  border-radius: var(--card-radius);
  background: var(--edu-feature-box-grad, linear-gradient(145deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 251, 255, 0.92) 52%, rgba(236, 244, 255, 0.78) 100%));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.82) inset,
    0 0 0 1px rgba(47, 107, 255, 0.06),
    0 8px 22px rgba(15, 41, 66, 0.07);
}

.q-interaction-controls,
.q-interaction-panel-side {
  padding: 10px 12px;
  border: 1px solid rgba(47, 107, 255, 0.14);
  border-radius: var(--card-radius);
  background: var(--edu-feature-box-grad, linear-gradient(145deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 251, 255, 0.92) 52%, rgba(236, 244, 255, 0.78) 100%));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.82) inset,
    0 0 0 1px rgba(47, 107, 255, 0.06),
    0 8px 22px rgba(15, 41, 66, 0.07);
}

.q-problem-panel .q-text,
.q-input-panel textarea.q-text {
  width: 100%;
  flex: 1;
  min-height: 0;
  height: auto;
  padding: 12px 14px;
  font-size: var(--fs-xs);
  line-height: 1.45;
  border: 1px solid rgba(47, 107, 255, 0.22);
  border-radius: var(--card-radius);
  resize: none;
  background: #ffffff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 1),
    0 1px 0 rgba(222, 233, 248, 0.98),
    0 2px 0 rgba(208, 222, 242, 0.62),
    0 3px 6px rgba(15, 41, 66, 0.05),
    0 8px 20px rgba(15, 41, 66, 0.08);
}

.q-problem-panel .q-text:focus {
  outline: none;
  border-color: rgba(255, 122, 61, 0.55);
  box-shadow:
    0 0 0 3px rgba(255, 122, 61, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 1),
    0 1px 0 rgba(222, 233, 248, 0.98),
    0 3px 8px rgba(47, 107, 255, 0.1),
    0 10px 24px rgba(15, 41, 66, 0.09);
}

.q-illus-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 3;
  min-height: 120px;
  flex-shrink: 0;
  box-sizing: border-box;
  margin: 0;
  border: 2px solid var(--border-strong);
  border-radius: var(--card-radius);
  overflow: hidden;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.q-illus-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #fff;
}

.q-illus-placeholder {
  font-size: var(--fs-xs);
  color: #64748b;
  text-align: center;
  padding: 12px;
}

.q-illus-edit {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 8px;
  background: rgba(15, 41, 66, 0.72);
  color: #fff;
  cursor: pointer;
}

.q-illus-edit svg {
  width: 16px;
  height: 16px;
  display: block;
}

.q-illus-edit:hover {
  background: rgba(15, 41, 66, 0.88);
}

.btn-image-ocr,
.btn-illus-upload {
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--panel, #fff);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.btn-image-ocr:hover,
.btn-illus-upload:hover {
  border-color: var(--teal, var(--blue));
  background: color-mix(in srgb, var(--blue) 12%, var(--panel, #fff));
  color: var(--blue);
}

.btn-image-ocr[hidden] { display: none !important; }

.q-options-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.q-answer-type-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.q-answer-type-row > label {
  font-size: var(--fs-xs);
  font-weight: 800;
  color: var(--navy);
  flex-shrink: 0;
}

.q-answer-type {
  min-width: 200px;
  padding: 8px 12px;
  font-size: var(--fs-xs);
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.q-answer-type:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.q-answer-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.q-answer-hint {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--muted);
  line-height: 1.4;
}

.q-fill-answers,
.q-match-pairs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.q-fill-row,
.q-match-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid rgba(47, 107, 255, 0.16);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 1),
    0 1px 0 rgba(222, 233, 248, 0.9),
    0 3px 10px rgba(15, 41, 66, 0.06);
}

.q-fill-row input,
.q-match-row input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  font-size: var(--fs-xs);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.q-match-arrow {
  flex-shrink: 0;
  color: var(--muted);
  font-weight: 700;
}

.q-options-block > label {
  font-size: var(--fs-xs);
  font-weight: 800;
  color: var(--navy);
}

.q-options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.q-illus-crop-frame {
  aspect-ratio: 5 / 3;
  max-height: 70vh;
  max-width: 100%;
  margin: 0 auto;
  background: #000;
}

/* Image OCR modal — đồng bộ create */
.image-ocr-modal[hidden] { display: none !important; }
.image-ocr-modal {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: grid;
  place-items: center;
  padding: 16px;
}
.image-ocr-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}
.image-ocr-sheet {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  max-height: min(92vh, 900px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  overflow: hidden;
}
.image-ocr-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.image-ocr-head h2 { margin: 0; font-size: var(--fs-sm); font-weight: 800; }
.image-ocr-close {
  border: none;
  background: transparent;
  font-size: var(--type-title);
  line-height: 1;
  color: var(--muted);
}
.image-ocr-body { padding: 16px 20px 20px; overflow: auto; }
.image-ocr-hint {
  margin: 0 0 12px;
  font-size: var(--fs-xs);
  color: var(--muted);
  line-height: 1.45;
}
.image-ocr-crop-wrap {
  width: 100%;
  max-height: 50vh;
  background: #f1f5f9;
  border-radius: var(--card-radius);
  overflow: hidden;
}
.image-ocr-crop-wrap img { max-width: 100%; display: block; }
.image-ocr-preview {
  width: 100%;
  padding: 12px;
  font-size: var(--fs-xs);
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  resize: vertical;
}
.image-ocr-status { font-size: var(--fs-xs); color: var(--muted); margin-top: 10px; }
.image-ocr-status.is-error { color: var(--bad); }
.image-ocr-status[hidden] { display: none; }
.image-ocr-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

/* Brief tab */
.game-brief-editor {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brief-row {
  display: grid;
  grid-template-columns: 1fr 180px 1fr;
  gap: 14px;
  margin-bottom: 12px;
}

.brief-row-3col {
  grid-template-columns: 1fr 1fr 1.15fr 0.85fr;
}

.brief-color-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brief-color-picker select {
  flex: 1;
  min-width: 0;
}

.brief-color-dot {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(15, 41, 66, 0.12);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.brief-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.brief-field > span {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--muted);
}

.brief-field input,
.brief-field select {
  padding: 10px 12px;
  font-size: var(--fs-xs);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.brief-field input.is-invalid,
.brief-field select.is-invalid {
  border-color: var(--bad);
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.15);
}

.brief-field > span.is-invalid-label {
  color: var(--bad);
}

.brief-chat-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--line-soft);
  padding-top: 14px;
}

.brief-chat-box label {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--muted);
}

.brief-chat-box textarea {
  width: 100%;
  min-height: 120px;
  padding: 14px 16px;
  font-size: var(--fs-xs);
  line-height: 1.45;
  border: 1px solid var(--line-accent);
  border-radius: var(--card-radius);
  resize: vertical;
  background: #f8fbff;
}

.brief-chat-box textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

@media (max-width: 1100px) {
  .brief-row,
  .brief-row-3col { grid-template-columns: 1fr; }
}

/* —— Tag chips (phân loại / gắn nhãn) —— */
.qc-tag-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px 0 12px;
}

.qc-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tag-color, #2563eb) 18%, #fff);
  border: 1px solid color-mix(in srgb, var(--tag-color, #2563eb) 45%, #fff);
}

.qc-tag-chip.is-active {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tag-color, #2563eb) 35%, transparent);
}

.qc-tag-input {
  border: none;
  background: transparent;
  min-width: 64px;
  max-width: 180px;
  padding: 2px 0;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--navy);
}

.qc-tag-input:focus {
  outline: none;
}

.qc-tag-remove,
.qc-tag-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 999px;
  border: 1px dashed var(--line);
  background: #fff;
  color: var(--blue);
  font-size: var(--type-body);
  font-weight: 800;
  line-height: 1;
}

.qc-tag-remove {
  border: none;
  background: transparent;
  color: var(--muted);
  width: 22px;
  height: 22px;
}

/* —— Gắn nhãn / điểm nóng: 2 cột (trái = nhãn/vùng, phải = ảnh nhỏ thẳng cột minh họa) —— */
.q-interaction-split {
  margin-top: 4px;
}

.q-interaction-controls {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.q-interaction-panel-side {
  flex: 0 0 34%;
  width: 34%;
  min-width: 180px;
  max-width: 34%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.q-interaction-frame--compact {
  width: 100%;
  max-height: 108px;
  aspect-ratio: 5 / 3;
  flex-shrink: 0;
}

.q-interaction-controls .btn-open-region-editor {
  align-self: flex-start;
  margin-top: 4px;
}

.qc-tag-add-inline {
  font-size: var(--fs-xs);
  font-weight: 700;
  padding: 4px 10px;
}

/* —— Compact option rows (1 dòng khi chưa có tệp) —— */
.q-option-row:not(.has-attachment) {
  align-items: center;
}

.q-option-row:not(.has-attachment) .opt-content {
  flex-direction: row;
  align-items: center;
}

.q-option-row:not(.has-attachment) .btn-opt-attach--answer,
.q-match-row-media .match-side:not(.has-attachment) .btn-match-attach {
  align-self: center;
}

/* —— Ghép cặp có media —— */
.q-match-row-media {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  padding: 10px 12px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid rgba(47, 107, 255, 0.16);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 1),
    0 1px 0 rgba(222, 233, 248, 0.9),
    0 3px 10px rgba(15, 41, 66, 0.06);
}

.match-side {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.match-side.has-attachment {
  grid-template-columns: 1fr;
  align-items: start;
}

.match-side-text {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: var(--fs-xs);
}

.q-match-arrow {
  align-self: center;
  color: var(--muted);
  font-weight: 800;
}

/* —— Ảnh tương tác (gắn nhãn / điểm nóng) —— */
.q-answer-warn {
  color: var(--warn);
}

.q-sub-label {
  margin-top: 12px;
}

/* —— Kéo thả tab câu hỏi —— */
.folder-tab.folder-tab-q.is-dragging {
  opacity: 0.45;
}

.folder-tab.folder-tab-q.drag-over {
  box-shadow: inset 0 -3px 0 var(--blue);
}

/* —— Region editor modal —— */
.region-editor-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.region-editor-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.region-editor-labels[hidden] {
  display: none !important;
}

#region-editor-draw-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.region-editor-hint {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--muted);
}

.region-editor-toolbar {
  display: flex;
  gap: 8px;
}

#region-editor-draw-btn.is-active {
  border-color: var(--blue);
  color: var(--blue);
  background: #eff6ff;
}

.region-editor-canvas-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  max-width: 100%;
  margin: 0 auto;
  user-select: none;
  border: 2px solid var(--border-strong);
  border-radius: var(--card-radius);
  background: #fff;
  padding: 4px;
  overflow: visible;
}

.region-editor-stage {
  position: relative;
  display: block;
  flex: 0 0 auto;
  max-width: 100%;
  line-height: 0;
  touch-action: none;
  overflow: visible;
}

.region-editor-stage img {
  display: block;
  max-width: 100%;
  max-height: 55vh;
  width: auto;
  height: auto;
}

.region-editor-overlay {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  overflow: visible;
}

.region-box {
  position: absolute;
  border: 2px solid #2563eb;
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.12);
  pointer-events: auto;
  cursor: move;
  box-sizing: border-box;
}

.region-box.is-active {
  border-color: #ea580c;
  box-shadow: 0 0 0 2px rgba(234, 88, 12, 0.25);
}

.region-box-tag {
  position: absolute;
  top: 4px;
  left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--type-meta);
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  max-width: calc(100% - 12px);
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.region-box-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: var(--type-meta);
  line-height: 1;
  cursor: pointer;
}

.region-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #fff;
  border: 2px solid #2563eb;
  border-radius: 2px;
  pointer-events: auto;
}

.region-handle-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.region-handle-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.region-handle-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.region-handle-se { bottom: -5px; right: -5px; cursor: nwse-resize; }

.q-image-clear {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.92);
  color: #fff;
  font-size: var(--type-body);
  line-height: 1;
  cursor: pointer;
}

.opt-attach-edit {
  position: absolute;
  right: 36px;
  bottom: 6px;
  z-index: 2;
  width: 28px;
  height: 28px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--navy);
  cursor: pointer;
}

.opt-attach-edit svg {
  width: 14px;
  height: 14px;
}

.opt-attach-preview--image {
  position: relative;
}

.opt-attach-preview--image .opt-attach-clear {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
}

/* Dark: ghost / secondary controls must stay readable on elevated surfaces */
html[data-theme="dark"] .btn-ghost,
html[data-theme="dark"] .btn-opt-image,
html[data-theme="dark"] .btn-opt-attach,
html[data-theme="dark"] .opt-attach-edit {
  background: linear-gradient(180deg, rgba(42, 62, 98, 0.95), rgba(22, 36, 60, 0.98));
  border-color: rgba(147, 197, 253, 0.42);
  color: #f0f6ff;
  -webkit-text-fill-color: #f0f6ff;
}

html[data-theme="dark"] .btn-ghost:hover:not(:disabled),
html[data-theme="dark"] .btn-opt-image:hover,
html[data-theme="dark"] .btn-opt-attach:hover {
  color: #fff;
  -webkit-text-fill-color: #fff;
  border-color: rgba(255, 154, 92, 0.65);
}
