:root {
  --bg: #f7f3ea;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --line: #ded6c8;
  --line-strong: #c7b9a8;
  --text: #25211d;
  --muted: #756b60;
  --sidebar: #3a261e;
  --sidebar-soft: #4a3126;
  --primary: #246bfe;
  --primary-dark: #1552cf;
  --warning: #d97706;
  --success: #168a4a;
  --danger: #c83b32;
  --shadow: 0 18px 45px rgba(45, 34, 24, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Arial, "Noto Sans KR", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.creator-login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #f6f0e6;
}

.creator-login-shell {
  width: min(440px, calc(100vw - 32px));
}

.creator-login-panel {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 34px;
}

.creator-login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.creator-login-brand img {
  width: 58px;
  height: 58px;
  object-fit: contain;
}

.creator-login-eyebrow {
  font-size: 14px;
  color: var(--muted);
  font-weight: 700;
}

.creator-login-brand h1 {
  margin: 3px 0 0;
  font-size: 28px;
  line-height: 1.1;
}

.creator-login-form {
  display: grid;
  gap: 14px;
}

.creator-login-form label,
.field {
  display: grid;
  gap: 7px;
}

.creator-login-form span,
.field span,
.compact-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.creator-login-form input,
.field input,
.field select,
.field textarea,
.list-toolbar input,
.list-toolbar select,
.choice-input input,
.choice-target-select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 9px 11px;
  outline: none;
}

.field textarea {
  min-height: 124px;
  resize: vertical;
  line-height: 1.55;
}

.creator-login-form input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus,
.list-toolbar input:focus,
.list-toolbar select:focus,
.choice-input input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(36, 107, 254, 0.14);
}

.creator-primary-button,
.secondary-button,
.text-button,
.list-toolbar button,
.image-dropzone button,
.attachment-actions button,
.choice-input button,
.creator-account button {
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 8px 14px;
  font-weight: 700;
}

.creator-primary-button {
  background: var(--primary);
  color: #fff;
}

.creator-primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button,
.list-toolbar button,
.image-dropzone button {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--text);
}

.text-button {
  background: transparent;
  border-color: transparent;
  color: var(--primary);
  padding-inline: 4px;
}

.creator-login-error,
.creator-login-hint {
  margin: 0;
  font-size: 13px;
}

.creator-login-error {
  color: var(--danger);
}

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

.creator-login-link {
  display: inline-block;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.creator-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.creator-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--sidebar);
  color: #fffaf3;
  padding: 20px 14px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  background: transparent;
  border: 0;
  color: inherit;
  text-align: left;
  padding: 8px;
}

.brand-lockup img {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
}

.brand-lockup strong,
.brand-lockup small {
  display: block;
}

.brand-lockup strong {
  font-size: 16px;
}

.brand-lockup small {
  margin-top: 3px;
  color: #d9c9b8;
  font-size: 12px;
  font-weight: 800;
}

.creator-nav {
  display: grid;
  align-content: start;
  gap: 6px;
  margin-top: 28px;
}

.creator-nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: #f5ebdd;
  padding: 9px 12px;
  text-align: left;
  font-weight: 800;
}

.creator-nav button:hover,
.creator-nav button.active {
  background: var(--sidebar-soft);
}

.creator-nav span {
  width: 22px;
  text-align: center;
}

.creator-account {
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  padding-top: 16px;
  display: grid;
  gap: 9px;
}

.creator-account strong {
  font-size: 14px;
}

.creator-account button {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.28);
  color: #fffaf3;
}

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

.creator-topbar {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.creator-topbar h1 {
  margin: 2px 0 0;
  font-size: 24px;
  line-height: 1.2;
}

.back-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  font-size: 13px;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.app-message {
  margin: 0 0 12px;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 700;
}

.app-message-error {
  color: var(--danger);
  background: #fff0ee;
  border: 1px solid #f1b9b3;
}

.app-message-success {
  color: var(--success);
  background: #eef9f2;
  border: 1px solid #bde7cc;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(390px, 1.45fr) minmax(290px, 1fr);
  gap: 12px;
  align-items: start;
}

.editor-panel,
.table-panel,
.bulk-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.editor-panel {
  padding: 16px;
}

.editor-panel h2 {
  margin: 0 0 16px;
  font-size: 16px;
}

.meta-panel {
  display: grid;
  gap: 12px;
}

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

.type-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
}

.segmented-control {
  display: flex;
  gap: 4px;
  margin-top: 7px;
  padding: 3px;
  background: #eee7dc;
  border-radius: 7px;
}

.segmented-control button {
  min-height: 34px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  padding: 7px 12px;
  font-weight: 800;
}

.segmented-control button.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 5px rgba(31, 25, 18, 0.12);
}

.status-field {
  min-width: 126px;
}

.image-tool {
  display: grid;
  gap: 10px;
}

.image-targets {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.image-targets label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text);
  font-weight: 700;
}

.choice-target-select {
  width: auto;
  min-height: 34px;
}

.image-dropzone {
  min-height: 142px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border: 1px dashed #9aa8bf;
  border-radius: 8px;
  background: #f8fbff;
  color: var(--muted);
  text-align: center;
}

.image-dropzone strong {
  color: #374151;
}

.hidden-file {
  display: none;
}

.upload-state {
  margin: 0;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.attachment-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.attachment-item,
.media-item {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.attachment-preview,
.media-item div {
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  background: #eef2f7;
  color: var(--muted);
  font-size: 13px;
}

.attachment-preview img,
.attachment-preview video,
.media-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.attachment-item figcaption,
.media-item figcaption {
  display: grid;
  gap: 3px;
  padding: 9px;
  font-size: 12px;
}

.attachment-item figcaption span,
.media-item figcaption span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.attachment-item em {
  color: var(--warning);
  font-style: normal;
}

.attachment-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
}

.attachment-actions button {
  min-height: 32px;
  border-radius: 0;
  border: 0;
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 4px;
  font-size: 12px;
}

.attachment-actions button:last-child {
  border-right: 0;
  color: var(--danger);
}

.image-editor-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(17, 24, 39, 0.62);
}

.image-editor-dialog {
  width: min(1180px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.image-editor-header,
.image-editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.image-editor-header div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.image-editor-header strong {
  font-size: 17px;
}

.image-editor-header span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.image-editor-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

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

.image-editor-error {
  margin: 12px 16px 0;
  border: 1px solid #f5b7b1;
  border-radius: 8px;
  background: #fff2f0;
  color: var(--danger);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
}

.image-editor-body {
  min-height: min(68vh, 720px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 0;
  overflow: hidden;
}

.image-editor-stage {
  min-width: 0;
  min-height: 420px;
  background: #111827;
}

.image-editor-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.image-editor-tools {
  display: grid;
  align-content: start;
  gap: 10px;
  border-left: 1px solid var(--line);
  background: #f8fafc;
  padding: 14px;
  overflow: auto;
}

.image-editor-targets {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.image-editor-target-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.image-editor-tool-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.image-editor-tool-row-two {
  grid-template-columns: 1fr 1fr;
}

.image-editor-tools button {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 800;
}

.image-editor-tools button.active {
  border-color: var(--primary);
  background: #edf4ff;
  color: var(--primary-dark);
}

.image-editor-range {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.image-editor-range input {
  width: 100%;
}

.image-editor-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.image-editor-field textarea,
.image-editor-field input[type="color"] {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
}

.image-editor-field textarea {
  min-height: 72px;
  resize: vertical;
  padding: 9px 10px;
  color: var(--text);
  font: inherit;
  line-height: 1.45;
}

.image-editor-field input[type="color"] {
  height: 38px;
  padding: 4px;
}

.ox-answer,
.choice-header,
.editor-footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ox-answer {
  color: var(--muted);
  font-weight: 800;
}

.ox-answer label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text);
}

.choice-editor {
  display: grid;
  gap: 10px;
}

.choice-header {
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

.choice-input {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.choice-number {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--primary);
  font-weight: 900;
}

.choice-input button {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.choice-input .choice-remove-button {
  color: var(--danger);
}

.choice-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.choice-image-strip {
  grid-column: 2 / 4;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.choice-image-thumb {
  width: 64px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.choice-image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.answer-select {
  max-width: 160px;
}

.editor-footer-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.preview-panel {
  position: sticky;
  top: 18px;
}

.student-preview {
  background: #fff;
  border: 1px solid #dbe2ea;
  border-radius: 8px;
  padding: 16px;
  min-height: 420px;
}

.student-preview-head {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  margin-bottom: 12px;
}

.preview-source-schools {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  margin-bottom: 12px;
  border: 1px solid #d8e4f2;
  border-radius: 999px;
  padding: 4px 10px;
  background: #f4f8ff;
  color: #315f9f;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
}

.preview-question {
  white-space: pre-wrap;
  line-height: 1.65;
  margin: 0 0 12px;
}

.preview-image {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  margin: 8px 0;
}

.preview-choices {
  display: grid;
  gap: 9px;
  margin: 16px 0 0;
  padding-left: 0;
  list-style: none;
}

.preview-choices li {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  column-gap: 8px;
  align-items: start;
  line-height: 1.5;
}

.preview-choice-label {
  font-weight: 800;
  line-height: 1.5;
}

.preview-choice-text {
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.preview-choices .preview-image {
  grid-column: 2;
  margin-top: 6px;
}

.preview-choices-image-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 12px;
}

.preview-choices-image-grid li {
  grid-template-columns: max-content minmax(0, 1fr);
  align-content: start;
  min-width: 0;
}

.preview-choices-image-grid .preview-image {
  grid-column: 1 / -1;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: none;
  margin: 6px 0 0;
}

.preview-ox {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.preview-ox span {
  min-height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-weight: 900;
}

.preview-short-answer {
  min-height: 46px;
  display: flex;
  align-items: center;
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-weight: 800;
  color: var(--text);
  background: #f8fafc;
}

.preview-answer-image {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.list-toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr)) minmax(220px, 1.6fr) auto;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.table-panel {
  overflow: auto;
}

.question-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

.question-table th,
.question-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  font-size: 14px;
  vertical-align: middle;
}

.question-table th {
  color: var(--muted);
  font-size: 12px;
  background: #fbf7ef;
}

.question-table tr[data-question-row] {
  cursor: pointer;
}

.question-table tr[data-question-row]:hover {
  background: #f4f8ff;
}

.empty-cell,
.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 34px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 900;
  background: #f0eee9;
  color: var(--muted);
}

.status-draft {
  background: #f0eee9;
}

.status-submitted,
.status-reviewing {
  background: #fff3df;
  color: var(--warning);
}

.status-approved,
.status-auto_approved {
  background: #e8f7ee;
  color: var(--success);
}

.bulk-panel {
  padding: 18px;
  display: grid;
  gap: 18px;
}

.bulk-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.bulk-summary,
.work-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
}

.bulk-summary div,
.work-metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.bulk-summary strong,
.work-metric strong {
  display: block;
  font-size: 28px;
}

.bulk-summary span,
.work-metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.bulk-preview {
  min-height: 260px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

.app-loading {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 900;
}

@media (max-width: 1180px) {
  .editor-grid {
    grid-template-columns: minmax(220px, 0.8fr) minmax(360px, 1.2fr);
  }

  .preview-panel {
    position: static;
    grid-column: 1 / -1;
  }

  .list-toolbar {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }
}

@media (max-width: 860px) {
  .image-editor-backdrop {
    padding: 10px;
  }

  .image-editor-dialog {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }

  .image-editor-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(320px, 58vh) auto;
  }

  .image-editor-stage {
    min-height: 320px;
  }

  .image-editor-tools {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .image-editor-tool-row,
  .image-editor-range {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .creator-shell {
    grid-template-columns: 1fr;
  }

  .creator-sidebar {
    position: static;
    height: auto;
    grid-template-rows: auto auto auto;
  }

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

  .creator-main {
    padding: 14px;
  }

  .creator-topbar,
  .type-row {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .editor-footer-actions {
    justify-content: stretch;
  }

  .topbar-actions button,
  .editor-footer-actions button {
    flex: 1;
  }

  .editor-grid,
  .list-toolbar,
  .bulk-summary,
  .work-grid {
    grid-template-columns: 1fr;
  }

  .choice-input {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .choice-actions,
  .choice-image-strip {
    grid-column: 2;
  }

  .choice-actions {
    flex-wrap: wrap;
  }
}
