:root {
  --editor-ink: #173548;
  --editor-muted: #667d89;
  --editor-line: #d5e1e5;
  --editor-pale: #f2f7f8;
  --editor-paper: #fffdfa;
  --editor-blue: #196b93;
  --editor-blue-dark: #124c6a;
  --editor-blue-pale: #e6f4f8;
  --editor-gold: #d28a21;
  --editor-gold-pale: #fff3d2;
  --editor-shadow: 0 10px 30px rgba(19, 55, 72, .10);
  --editor-radius: 16px;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: #eaf2f3; }

body {
  min-width: 320px;
  margin: 0;
  background: linear-gradient(145deg, #f5fbfb 0%, #e9f2f3 54%, #fdf8ec 100%);
  color: var(--editor-ink);
  font: 400 16px/1.5 "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #f2b13a;
  outline-offset: 2px;
}

.editor-app { min-height: 100dvh; }
.editor-app.is-restoring .editor-workspace { opacity: .72; pointer-events: none; }

.editor-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(16px, 4vw, 56px) 20px;
  border-bottom: 1px solid #cbdce0;
  background: rgba(255, 255, 255, .88);
}

.header-copy { min-width: 0; }
.eyebrow, .pane-kicker {
  margin: 0 0 5px;
  color: var(--editor-blue);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.editor-header h1 {
  margin: 0;
  color: #12384e;
  font-size: clamp(25px, 3vw, 38px);
  font-weight: 900;
  letter-spacing: -.04em;
  line-height: 1.2;
}

.editor-header h1 span {
  display: inline-block;
  margin-left: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--editor-gold-pale);
  color: #936019;
  font-size: .42em;
  letter-spacing: .03em;
  vertical-align: middle;
}

.header-subtitle {
  max-width: 820px;
  margin: 6px 0 0;
  color: var(--editor-muted);
  font-size: 15px;
}

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

.storage-tools {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.storage-tools .header-button {
  min-height: 32px;
  padding: 4px 8px;
  font-size: 13px;
}

.import-button { display: inline-flex; align-items: center; cursor: pointer; }
.import-button input { position: absolute; top: 0; left: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.storage-status { max-width: 230px; color: var(--editor-muted); font-size: 12px; line-height: 1.25; text-align: right; }
.storage-more { position: relative; }
.storage-more summary { display: inline-flex; align-items: center; min-height: 32px; padding: 4px 8px; border: 1px solid #abc3cb; border-radius: 9px; background: #fff; color: var(--editor-blue-dark); cursor: pointer; font-size: 13px; font-weight: 800; list-style: none; }
.storage-more summary::-webkit-details-marker { display: none; }
.storage-more summary::after { margin-left: 5px; content: '▾'; font-size: 11px; }
.storage-more-menu { position: absolute; top: calc(100% + 4px); right: 0; z-index: 25; display: grid; min-width: 154px; gap: 5px; padding: 6px; border: 1px solid #bfd4d8; border-radius: 9px; background: #fff; box-shadow: 0 10px 24px rgba(20, 58, 72, .16); }
.storage-more-menu .header-button { width: 100%; text-align: left; }

.source-badge, .read-only-chip, .student-only-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid #bad6dd;
  border-radius: 999px;
  background: #edf8fa;
  color: var(--editor-blue-dark);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.source-badge.is-warning {
  border-color: #e8bf79;
  background: #fff6df;
  color: #8c5c1b;
}

.header-button, .filter-reset {
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid #abc3cb;
  border-radius: 9px;
  background: #fff;
  color: var(--editor-blue-dark);
  font-size: 14px;
  font-weight: 800;
}

.header-button:hover, .filter-reset:hover { border-color: var(--editor-blue); background: #f3fbfc; }

.editor-notice {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 1900px;
  margin: 14px auto 0;
  padding: 10px 16px;
  border: 1px solid #e8d197;
  border-radius: 12px;
  background: rgba(255, 249, 230, .94);
  color: #66502b;
  font-size: 14px;
}

.notice-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--editor-gold);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.edit-status {
  margin-left: auto;
  color: #896b31;
  font-size: 13px;
  white-space: nowrap;
}

.editor-workspace {
  display: grid;
  grid-template-columns: minmax(224px, .72fr) minmax(360px, 1.08fr) minmax(330px, 1fr);
  gap: 14px;
  max-width: 1900px;
  min-height: calc(100dvh - 164px);
  margin: 0 auto;
  padding: 14px;
}

.workspace-pane {
  min-width: 0;
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--editor-line);
  border-radius: var(--editor-radius);
  background: rgba(255, 253, 250, .94);
  box-shadow: var(--editor-shadow);
}

.bank-pane, .edit-pane, .preview-pane { display: flex; flex-direction: column; }

.pane-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px 9px;
  border-bottom: 1px solid #e1e9eb;
  background: linear-gradient(180deg, #fff 0%, #fbfdfc 100%);
}

.pane-heading h2 {
  margin: 0;
  color: #173d52;
  font-size: 21px;
  font-weight: 900;
  letter-spacing: -.03em;
}

.pane-kicker { margin-bottom: 2px; font-size: 12px; }
.result-count { color: var(--editor-blue); font-size: 14px; white-space: nowrap; }
.read-only-chip { border-color: #ded1ad; background: #fff8e5; color: #88601f; }
.student-only-chip { border-color: #abd4c5; background: #eefaf4; color: #287259; font-size: 12px; }

.bank-source-card {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 12px 13px 6px;
  padding: 9px 10px;
  border: 1px solid #cce1e5;
  border-radius: 11px;
  background: var(--editor-blue-pale);
}

/* The workbench selector already identifies the active bank; keep this source note in the DOM for status updates without adding another tall row. */
.bank-source-card { display: none; }

.source-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #28a27e;
  box-shadow: 0 0 0 4px #28a27e22;
}

.bank-source-card div { display: grid; min-width: 0; }
.bank-source-card strong { font-size: 14px; }
.bank-source-card span { overflow: hidden; color: var(--editor-muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.workbench-controls { display: grid; gap: 8px; margin: 7px 13px 8px; }
.workbench-controls label { display: grid; gap: 4px; }
.workbench-controls label > span { color: #526c78; font-size: 14px; font-weight: 800; }
.workbench-controls select { width: 100%; min-height: 38px; padding: 6px 9px; border: 1px solid #b9d2d7; border-radius: 8px; background: #fff; color: var(--editor-ink); font-size: 14px; }
.workbench-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.workbench-buttons button { min-height: 35px; padding: 5px 7px; border: 1px solid #9dc6ce; border-radius: 8px; background: #edf8f9; color: var(--editor-blue-dark); font-size: 13px; font-weight: 900; }
.workbench-buttons button:hover { border-color: var(--editor-blue); background: #dff2f4; }
.workbench-buttons button:disabled { cursor: not-allowed; opacity: .48; }

.filter-form { padding: 8px 13px 10px; border-bottom: 1px solid #e1e9eb; }
.filter-form label, .filter-form label > span { display: grid; gap: 4px; }
.filter-form label > span { color: #526c78; font-size: 14px; font-weight: 800; }
.search-field { margin-bottom: 9px; }
.search-control { position: relative; display: block; }
.search-control .search-icon { position: absolute; top: 50%; left: 10px; display: block; transform: translateY(-52%); color: var(--editor-blue); font-size: 21px; line-height: 1; pointer-events: none; }

.filter-form input, .filter-form select {
  width: 100%;
  min-height: 38px;
  padding: 6px 9px;
  border: 1px solid #bed0d5;
  border-radius: 8px;
  background: #fff;
  color: var(--editor-ink);
  font-size: 14px;
}

.filter-form input { padding-left: 32px; }
.filter-form input::placeholder { color: #91a3aa; }
.filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.filter-grid label:last-child { grid-column: 1 / -1; }
.filter-reset { width: 100%; margin-top: 9px; min-height: 33px; font-size: 13px; }
.filter-details { margin-top: 7px; }
.filter-details summary { width: max-content; padding: 4px 0; color: var(--editor-blue-dark); cursor: pointer; font-size: 14px; font-weight: 900; }
.filter-details[open] summary { margin-bottom: 6px; }

.list-help {
  margin: 0;
  padding: 9px 14px 5px;
  color: var(--editor-muted);
  font-size: 13px;
  line-height: 1.4;
}

.list-help { display: none; }

.question-list {
  flex: 1 1 auto;
  min-height: 160px;
  overflow: auto;
  padding: 5px 8px 12px;
  overscroll-behavior: contain;
}

.question-list-empty { padding: 30px 15px; color: var(--editor-muted); text-align: center; }

.question-list-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 10px 10px 9px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}

.question-list-item:hover { border-color: #c4dce2; background: #f3fafb; }
.question-list-item.is-selected { border-color: #73b5c8; background: #e9f7f8; box-shadow: inset 4px 0 0 var(--editor-blue); }
.question-list-item .item-top { display: flex; align-items: center; justify-content: space-between; gap: 7px; }
.question-list-item .item-code { color: var(--editor-blue-dark); font-size: 14px; font-weight: 900; }
.question-list-item .item-status { color: #6b818a; font-size: 12px; white-space: nowrap; }
.question-list-item .item-status.status-unreviewed { color: #4f6870; }
.question-list-item .item-status.status-review { color: #8b6322; }
.question-list-item .item-status.status-approved { color: #27734d; }
.question-list-item .item-status.status-excluded { color: #8b4545; }
.question-list-item .item-prompt { display: -webkit-box; overflow: hidden; margin-top: 3px; color: #244452; font-size: 14px; line-height: 1.35; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.question-list-item .item-meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; color: #6a8089; font-size: 12px; }
.question-list-item .item-meta span { padding: 1px 5px; border-radius: 4px; background: #f0f5f5; }
.question-list-item.is-selected .item-meta span { background: #d7eff2; }

.editor-content { flex: 1 1 auto; overflow: auto; padding: 14px; }
.editor-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.editor-toolbar h3 { margin: 0; color: #163d52; font-size: 20px; line-height: 1.3; }
.editor-toolbar p { margin: 3px 0 0; color: var(--editor-muted); font-size: 13px; }
.editor-toolbar .question-code { flex: 0 0 auto; padding: 5px 9px; border-radius: 7px; background: var(--editor-blue-dark); color: #fff; font-size: 13px; font-weight: 900; }

.editor-card {
  margin-bottom: 12px;
  padding: 13px;
  border: 1px solid #d8e4e6;
  border-radius: 13px;
  background: #fff;
}

.editor-card:last-child { margin-bottom: 0; }
.editor-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 9px; margin-bottom: 9px; }
.editor-card-heading h4 { margin: 0; color: #234c5d; font-size: 16px; font-weight: 900; }
.editor-card-heading span { color: var(--editor-muted); font-size: 12px; }
.meta-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.meta-field { min-width: 0; }
.meta-field > span, .editor-label { display: block; margin-bottom: 4px; color: #58727d; font-size: 14px; font-weight: 800; }
.meta-value { min-height: 35px; overflow: hidden; padding: 6px 8px; border: 1px solid #e0e9ea; border-radius: 7px; background: #f7faf9; color: #315463; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.meta-value.status-unreviewed { background: #f2f6f7; color: #4f6870; }
.meta-value.status-approved { background: #eefaf2; color: #27734d; }
.meta-value.status-review { background: #fff8e5; color: #8b6322; }
.meta-value.status-excluded { background: #f8eeee; color: #8b4545; }
.field-stack { display: grid; gap: 11px; }
.editor-field { display: grid; gap: 4px; }
.editor-field textarea { width: 100%; min-height: 84px; resize: vertical; padding: 9px 10px; border: 1px solid #bcd0d4; border-radius: 8px; background: #fffefa; color: #203f4e; font-size: 16px; line-height: 1.55; }
.editor-field textarea.prompt-field { min-height: 112px; }
.editor-field textarea[readonly] { border-color: #dfe7e8; background: #f4f7f6; color: #61767e; }
.field-help { margin: 0; color: #758a91; font-size: 12px; }
.field-required { color: #bd6c1f; font-size: 12px; }

.material-summary { display: flex; flex-wrap: wrap; gap: 6px; }
.material-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 7px; border: 1px solid #c8dfe2; border-radius: 6px; background: #f0fafb; color: #2a6274; font: 700 12px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; }
.material-chip.is-missing { border-color: #e9c2a2; background: #fff5ec; color: #9a5e2c; }
.teacher-only-note { border-left: 4px solid #d2a43e; background: #fffaf0; }
.teacher-only-note .editor-card-heading h4 { color: #765624; }
.structure-note { color: var(--editor-muted); font-size: 13px; line-height: 1.5; }
.structure-note strong { color: #2e5e6f; }
.empty-state { display: grid; min-height: 240px; place-items: center; padding: 30px; border: 1px dashed #bbd0d5; border-radius: 12px; color: var(--editor-muted); text-align: center; }

.preview-pane { min-width: 0; }
.preview-heading { flex: 0 0 auto; min-width: 0; }
.preview-heading > div { min-width: 0; }
.preview-heading .student-only-chip { min-width: 0; max-width: 48%; overflow-wrap: anywhere; white-space: normal; }
.preview-intro { margin: 0; padding: 9px 14px; color: #5d747c; font-size: 13px; }
.preview-controls { display: grid; grid-template-columns: minmax(160px, 1fr) auto; align-items: end; gap: 8px; padding: 5px 14px 8px; }
.preview-controls label { display: grid; gap: 4px; }
.preview-controls label > span { color: #526c78; font-size: 14px; font-weight: 800; }
.preview-controls select { min-height: 37px; padding: 5px 8px; border: 1px solid #b9d2d7; border-radius: 8px; background: #fff; color: var(--editor-ink); font-size: 14px; }
.preview-open-button { min-height: 37px; padding: 5px 10px; border: 1px solid #aac8cc; border-radius: 8px; background: #fff; color: var(--editor-blue-dark); font-size: 13px; font-weight: 900; }
.preview-open-button:hover { border-color: var(--editor-blue); background: #f2fbfc; }
.preview-size-note { grid-column: 1 / -1; padding: 0; color: var(--editor-muted); font-size: 12px; }
.iframe-preview { flex: 1 1 auto; min-height: 300px; overflow: hidden; padding: 0 12px 8px; }
.preview-viewport-shell { width: 100%; height: 610px; overflow: auto; border: 1px solid #cbdde0; border-radius: 13px; background: #dcebed; box-shadow: inset 0 0 0 5px #f4fbfb; }
.preview-viewport-shell.is-phone { --preview-width: 390px; --preview-height: 760px; }
.preview-viewport-shell.is-tablet { --preview-width: 1024px; --preview-height: 760px; }
.preview-iframe { display: block; width: var(--preview-width); min-width: var(--preview-width); height: var(--preview-height); min-height: var(--preview-height); border: 0; background: #f7fbfb; }
.preview-viewport-shell.is-phone .preview-iframe { margin: 0 auto; }
.runtime-loading { display: grid; min-height: 250px; place-items: center; padding: 20px; color: var(--editor-muted); font-size: 14px; text-align: center; }
.runtime-error { margin: 20px 5px; padding: 12px; border: 1px solid #e7b2a4; border-radius: 9px; background: #fff3ef; color: #8a493c; font-size: 13px; }
.preview-footnote { display: none; }

.mobile-tabs { display: none; }
.noscript-message { margin: 20px; padding: 15px; border: 2px solid #c96b52; border-radius: 10px; background: #fff1eb; color: #78372c; }

@media (max-width: 1199px) {
  .editor-workspace { grid-template-columns: minmax(220px, .74fr) minmax(0, 1.26fr); }
  .preview-pane { grid-column: 1 / -1; min-height: 600px; }
  .preview-controls { grid-template-columns: minmax(160px, 1fr) auto; }
}

@media (max-width: 999px) {
  .editor-header { align-items: flex-start; flex-direction: column; gap: 6px; padding: 10px 10px 8px; }
  .editor-header h1 { font-size: 24px; }
  .header-actions { display: grid; width: 100%; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 5px; }
  .header-copy { width: 100%; }
  .header-subtitle { margin-top: 2px; font-size: 12px; }
  .source-badge { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .storage-tools { grid-column: 2; max-width: 100%; gap: 4px; }
  .storage-tools .header-button { min-height: 31px; padding: 4px 7px; font-size: 12px; }
  .header-actions > #resetEdits { grid-column: 1 / -1; justify-self: start; min-height: 31px; padding: 4px 8px; font-size: 12px; }
  .storage-status { grid-column: 1 / -1; max-width: none; text-align: left; }
  .storage-more summary { min-height: 31px; padding: 4px 7px; font-size: 12px; }
  .storage-more-menu { right: 0; min-width: 148px; }
  .editor-notice { align-items: flex-start; flex-wrap: wrap; margin: 7px 8px 0; padding: 7px 8px; font-size: 12px; }
  .editor-notice > span:nth-child(2) { flex: 1 1 calc(100% - 31px); min-width: 0; }
  .edit-status { width: calc(100% - 31px); margin-left: 31px; font-size: 12px; line-height: 1.35; white-space: normal; overflow-wrap: anywhere; }
  html, body { height: 100%; overflow: hidden; }
  .editor-app { display: flex; height: 100dvh; min-height: 0; flex-direction: column; overflow: hidden; }
  .editor-workspace { display: block; width: 100%; max-width: 100%; flex: 1 1 0; height: 0; min-height: 0; padding: 10px 10px 74px; overflow: hidden; }
  .workspace-pane { display: none; height: 100%; min-height: 0; max-height: 100%; border-radius: 13px; }
  .workspace-pane.is-mobile-active { display: flex; min-height: 0; }
  .bank-pane.is-mobile-active { min-height: 200px; }
  .bank-pane .question-list { min-height: 200px; overflow: auto; }
  .edit-pane .editor-content { min-height: 0; overflow: auto; }
  .preview-pane.is-mobile-active { min-height: 0; }
  .mobile-tabs { position: fixed; right: 0; bottom: 0; left: 0; z-index: 20; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; padding: 6px max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)); border-top: 1px solid #b9d1d6; background: rgba(255, 255, 255, .96); box-shadow: 0 -5px 20px rgba(25, 65, 78, .12); }
  .mobile-tabs button { display: grid; gap: 1px; place-items: center; min-height: 48px; border: 0; border-radius: 8px; background: transparent; color: #6c8188; font-size: 12px; font-weight: 800; }
  .mobile-tabs button span { font-size: 18px; line-height: 1; }
  .mobile-tabs button.is-active { background: #e5f4f6; color: var(--editor-blue-dark); }
  .preview-controls { grid-template-columns: minmax(0, 1fr) minmax(0, auto); align-items: end; }
  .preview-controls label, .preview-open-button { min-width: 0; }
  .preview-controls label, .preview-controls select { width: 100%; }
  .preview-open-button { max-width: 100%; white-space: normal; }
  .preview-size-note { grid-column: 1 / -1; padding: 0; }
  .iframe-preview { flex: 1 1 auto; min-height: 300px; padding: 0 10px 10px; overflow: hidden; }
  .preview-viewport-shell { height: 100%; min-height: 300px; }
  .editor-toolbar { flex-direction: column; }
  .meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 430px) {
  .header-subtitle { display: none; }
  .pane-heading { padding: 13px 13px 10px; }
  .pane-heading h2 { font-size: 19px; }
  .editor-content { padding: 10px; }
  .editor-card { padding: 11px; }
  .meta-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .meta-value { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important; }
}

/* Dedicated type and review forms. These controls stay in the editor document; the iframe receives only q/materialMap. */
.forms-metadata-card, .forms-type-card { background: #fff; }
.form-grid { display: grid; gap: 9px; }
.form-grid-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-field { display: grid; min-width: 0; gap: 4px; }
.form-field > span, .form-check > span { color: #526c78; font-size: 14px; font-weight: 800; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%;
  min-height: 37px;
  padding: 6px 8px;
  border: 1px solid #bcd0d4;
  border-radius: 8px;
  background: #fffefa;
  color: #203f4e;
  font-size: 15px;
}
.form-field textarea { min-height: 76px; resize: vertical; line-height: 1.5; }
.form-field small, .form-check small { color: #71868e; font-size: 12px; line-height: 1.35; }
.form-check-row { display: flex; flex-wrap: wrap; gap: 9px 20px; margin-top: 10px; padding-top: 9px; border-top: 1px solid #e7eeee; }
.form-check { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 6px; min-height: 34px; }
.form-check input, .inline-check input { width: 18px; height: 18px; accent-color: var(--editor-blue); }
.form-check small { grid-column: 2; }
.form-teacher-fields { margin-top: 12px; padding-top: 11px; border-top: 1px solid #e2eaeb; }
.array-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 12px 0 7px; color: #2d5968; font-size: 14px; }
.array-heading:first-child { margin-top: 0; }
.array-heading span { color: var(--editor-muted); font-size: 12px; font-weight: 400; }
.array-add, .array-remove { min-height: 31px; padding: 4px 8px; border: 1px solid #acd0d4; border-radius: 7px; background: #f0fafb; color: var(--editor-blue-dark); font-size: 13px; font-weight: 900; }
.array-remove { border-color: #e2c1b2; background: #fff6f0; color: #8d513b; }
.array-add:hover { border-color: var(--editor-blue); }
.array-remove:hover { border-color: #c6795b; }
.array-list, .choice-list, .card-list, .step-choice-list { display: grid; gap: 7px; }
.array-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 6px; padding: 7px; border: 1px solid #d7e4e5; border-radius: 9px; background: #fbfdfc; }
.choice-row { grid-template-columns: 25px minmax(0, 1fr) auto minmax(0, .9fr) auto auto; }
.card-row { grid-template-columns: 25px minmax(0, 1fr) minmax(110px, .6fr) auto auto; }
.classify-item-row { grid-template-columns: 25px minmax(0, 1fr) minmax(110px, .65fr) auto auto; }
.staged-item { margin-top: 8px; padding: 10px; border: 1px solid #d6e4e5; border-radius: 10px; background: #f9fcfb; }
.staged-item:first-child { margin-top: 0; }
.staged-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; color: #2d5968; font-size: 14px; }
.staged-item > textarea { width: 100%; min-height: 67px; padding: 7px 8px; border: 1px solid #bcd0d4; border-radius: 7px; background: #fffefa; color: #203f4e; font-size: 15px; line-height: 1.45; resize: vertical; }
.nested-heading { margin-top: 10px; }
.row-index { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; background: #e2f1f3; color: #286276; font-size: 13px; font-weight: 900; }
.row-id { overflow: hidden; max-width: 112px; color: #6c8289; font: 700 12px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }
.array-row input, .array-row select, .order-select-row select { width: 100%; min-height: 34px; min-width: 0; padding: 5px 7px; border: 1px solid #c2d3d5; border-radius: 7px; background: #fff; color: #244653; font-size: 14px; }
.inline-check { display: inline-flex; align-items: center; gap: 4px; color: #506e79; font-size: 13px; white-space: nowrap; }
.answer-heading { margin-top: 15px; padding-top: 10px; border-top: 1px solid #e2eaeb; }
.order-answer-list { display: grid; gap: 10px; }
.answer-order-group { padding: 9px; border: 1px solid #d6e4e5; border-radius: 9px; background: #fbfdfc; }
.answer-order-group .array-heading { margin: 0 0 7px; }
.order-select-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.order-select-row label { display: grid; gap: 3px; min-width: 0; }
.order-select-row label > span { color: #6b8188; font-size: 12px; }
.pair-list { display: grid; gap: 7px; }
.pair-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 8px; padding: 7px 8px; border: 1px solid #d7e4e5; border-radius: 8px; background: #fbfdfc; color: #355d69; font-size: 14px; }
.legacy-note { margin: 0 0 9px; padding: 9px 10px; border-left: 4px solid #c99835; border-radius: 7px; background: #fff8e5; color: #745520; font-size: 13px; line-height: 1.45; }
.form-empty { margin: 0; color: var(--editor-muted); font-size: 14px; }
.validation-panel { margin: 0 14px 14px; padding: 10px 12px; border: 1px solid #e3c181; border-radius: 9px; background: #fff8e5; color: #72531d; font-size: 13px; line-height: 1.45; }
.validation-panel strong, .validation-panel span { display: block; }
.validation-panel ul { margin: 6px 0 0; padding-left: 20px; }
.validation-panel.is-valid { border-color: #acd6c2; background: #effaf4; color: #276a4d; }
.validation-panel.is-valid span { margin-top: 3px; color: #4f7f6c; }
.validation-panel.is-invalid { border-color: #e2b29d; background: #fff3ed; color: #864b3c; }
.validation-panel.is-invalid p { margin: 7px 0 0; color: #8e6c34; }

.storage-status[data-state="saving"], .storage-status[data-state="loading"] { color: #8a6928; }
.storage-status[data-state="saved"] { color: #2c7653; }
.storage-status[data-state="error"], .storage-status[data-state="conflict"] { color: #984c3b; }
.photo-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: end; gap: 8px; margin-top: 10px; }
.photo-upload-button { display: inline-flex; align-items: center; justify-content: center; min-height: 37px; cursor: pointer; white-space: nowrap; }
.photo-upload-button input { position: absolute; top: 0; left: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.photo-replace-button { display: inline-flex; align-items: center; cursor: pointer; white-space: nowrap; }
.photo-replace-button input { position: absolute; top: 0; left: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.photo-candidate { display: flex; min-height: 50px; align-items: center; gap: 8px; margin-top: 8px; padding: 6px 8px; border: 1px dashed #c4d9dc; border-radius: 8px; background: #f8fcfc; color: #647b82; font-size: 13px; }
.photo-candidate img { width: 54px; height: 42px; border-radius: 5px; object-fit: contain; background: #eaf3f4; }
.photo-candidate span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-candidate button { margin-left: auto; flex: 0 0 auto; }
.photo-notice { margin: 9px 0 0; padding: 7px 9px; border-radius: 8px; background: #f3f8f8; color: #607880; font-size: 13px; line-height: 1.4; }
.photo-notice.is-success { background: #edf9f3; color: #347154; }
.photo-notice.is-warning { background: #fff8e6; color: #84642b; }
.photo-notice.is-error { background: #fff2ed; color: #8d4c3d; }
.photo-list { display: grid; gap: 9px; margin-top: 10px; }
.photo-row { display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 10px; padding: 9px; border: 1px solid #d7e4e5; border-radius: 10px; background: #fbfdfc; }
.photo-preview-wrap { display: grid; min-height: 92px; place-items: center; overflow: hidden; border-radius: 8px; background: #eaf3f4; }
.photo-preview-button { display: block; width: 100%; height: 100%; min-height: 92px; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.photo-preview-button img { display: block; width: 100%; height: 100%; min-height: 92px; object-fit: contain; }
.photo-missing { padding: 10px; color: #8a6c56; font-size: 12px; text-align: center; }
.photo-row-content { display: grid; min-width: 0; gap: 6px; }
.photo-row-heading { display: flex; min-width: 0; align-items: baseline; justify-content: space-between; gap: 7px; }
.photo-row-heading strong { overflow: hidden; color: #285b6e; font: 800 13px/1.3 ui-monospace, SFMono-Regular, Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }
.photo-row-heading span { overflow: hidden; color: #71858b; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.photo-row .form-field { grid-template-columns: 62px minmax(0, 1fr); align-items: center; gap: 7px; }
.photo-row .form-field > span { font-size: 13px; }
.photo-row .form-field input { min-height: 33px; }
.photo-row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.photo-row-actions select { min-height: 31px; min-width: 0; max-width: 220px; padding: 4px 6px; border: 1px solid #c2d3d5; border-radius: 7px; background: #fff; color: #244653; font-size: 13px; }
.photo-lightbox { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 18px; background: rgba(13, 38, 48, .68); }
.photo-lightbox[hidden] { display: none; }
.photo-lightbox-card { display: grid; gap: 10px; max-width: min(94vw, 900px); max-height: 94vh; overflow: auto; padding: 14px; border-radius: 14px; background: #fffdf8; box-shadow: 0 18px 48px rgba(8, 33, 44, .3); }
.photo-lightbox-card button { justify-self: end; }
.photo-lightbox-card img { display: block; max-width: 100%; max-height: 76vh; object-fit: contain; }
.photo-lightbox-card p { margin: 0; color: #496b76; }

@media (max-width: 900px) {
  .form-grid-three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choice-row { grid-template-columns: 25px minmax(0, 1fr) auto; }
  .choice-row input[data-struct-field="choiceRationale"] { grid-column: 2 / -1; }
  .card-row, .classify-item-row { grid-template-columns: 25px minmax(0, 1fr) auto; }
  .card-row input[data-struct-field="cardMaterialId"], .classify-item-row select { grid-column: 2 / 3; }
  .card-row .row-id, .classify-item-row .row-id { grid-column: 3; grid-row: 1; }
  .card-row .array-remove, .classify-item-row .array-remove { grid-column: 3; grid-row: 2; }
  .order-select-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .form-grid-two, .form-grid-three { grid-template-columns: 1fr; }
  .array-row, .choice-row, .card-row, .classify-item-row { grid-template-columns: 25px minmax(0, 1fr) auto; }
  .choice-row input[data-struct-field="choiceRationale"], .card-row input[data-struct-field="cardMaterialId"], .classify-item-row select { grid-column: 2 / -1; }
  .row-id { max-width: 88px; }
  .pair-row { grid-template-columns: 1fr; gap: 5px; }
  .order-select-row { grid-template-columns: 1fr; }
  .photo-toolbar { grid-template-columns: minmax(0, 1fr) auto; }
  .photo-upload-button { grid-column: 1 / -1; }
  .photo-row { grid-template-columns: 82px minmax(0, 1fr); gap: 7px; padding: 7px; }
  .photo-preview-wrap, .photo-preview-button, .photo-preview-button img { min-height: 72px; }
  .photo-row .form-field { grid-template-columns: 1fr; gap: 2px; }
  .photo-row-actions select { flex: 1 1 130px; max-width: none; }
}

/* Desktop workbench: keep the three working surfaces in the viewport and scroll within each pane. */
@media (min-width: 1000px) {
  html, body { height: 100%; overflow: hidden; }
  .editor-app { display: flex; height: 100dvh; min-height: 0; flex-direction: column; overflow: hidden; }
  .editor-header { flex: 0 0 auto; min-height: 72px; padding: 13px 20px 10px; }
  .editor-header h1 { font-size: 29px; }
  .header-subtitle { margin-top: 3px; font-size: 13px; }
  .editor-notice { flex: 0 0 auto; margin: 7px 14px 0; padding: 7px 11px; }
  .editor-workspace { grid-template-columns: 220px minmax(330px, 1fr) minmax(320px, 1fr); grid-template-rows: minmax(0, 1fr); flex: 1 1 0; height: 0; min-height: 0; padding: 10px 14px 12px; gap: 10px; overflow: hidden; }
  .workspace-pane { height: 100%; min-height: 0; max-height: 100%; }
  .question-list, .editor-content { min-height: 0; }
  .edit-pane .form-grid-three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .edit-pane .choice-row { grid-template-columns: 25px minmax(0, 1fr) auto; }
  .edit-pane .choice-row input[data-struct-field="choiceRationale"] { grid-column: 2 / -1; }
  .edit-pane .card-row, .edit-pane .classify-item-row { grid-template-columns: 25px minmax(0, 1fr) auto; }
  .edit-pane .card-row input[data-struct-field="cardMaterialId"], .edit-pane .classify-item-row select { grid-column: 2 / 3; }
  .edit-pane .card-row .row-id, .edit-pane .classify-item-row .row-id { grid-column: 3; grid-row: 1; }
  .edit-pane .card-row .array-remove, .edit-pane .classify-item-row .array-remove { grid-column: 3; grid-row: 2; }
  .edit-pane .order-select-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preview-pane { grid-column: auto; min-height: 0; }
  .iframe-preview { min-height: 0; overflow: hidden; }
  .preview-viewport-shell { height: 100%; min-height: 0; }
  .preview-footnote { flex: 0 0 auto; margin-bottom: 10px; }
}
