/* Light-violet theme for the level editor components, matching workspace.css.
   Class names match what app.js emits, so the editor logic is unchanged. */

:root { --field-bg: #fbfbfd; }

/* page switching (shared) */
.page { display: none; }
.page.active { display: block; }

/* ── Editor split ──────────────────────────────────────────────────── */
.editor-split {
  display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px;
  height: calc(100dvh - 148px); min-height: 440px;
}
.lvpane, .editor {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; min-width: 0;
}

/* ── Buttons (editor uses .btn) ────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 8px; padding: 8px 13px; font-size: 12px; font-weight: 600;
  font-family: inherit; cursor: pointer; border: 1px solid transparent; min-height: 37px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s; white-space: nowrap;
}
.btn-sm { min-height: 32px; padding: 6px 10px; font-size: 11.5px; }
.btn-icon { padding: 0; width: 32px; min-height: 32px; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 3px 7px rgba(121,86,214,0.18); }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-outline { background: #fff; color: #70727f; border-color: var(--line); }
.btn-outline:hover { border-color: #cfc4e3; background: #faf8ff; color: var(--primary); }
.btn-danger { background: #fff; color: #cc5a66; border-color: #f4dfe2; }
.btn-danger:hover { background: #fdf3f4; border-color: #e9c3c8; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Level list pane ───────────────────────────────────────────────── */
.lv-actions { padding: 14px; display: flex; flex-wrap: wrap; gap: 8px; border-bottom: 1px solid var(--line); }
.lv-actions input[type=text] { flex: 1 1 100%; min-width: 0; min-height: 36px; }
.lv-actions > .btn { flex: 1; }
input, select, textarea {
  border: 1px solid #e3e4ed; background: var(--field-bg); border-radius: 8px;
  color: var(--ink); font-size: 13px; padding: 8px 10px; font-family: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bcb0ed; outline-offset: 1px; border-color: transparent; }

.tab-bar { display: flex; gap: 4px; padding: 8px 12px 0; border-bottom: 1px solid var(--line); }
.tab-bar button { flex: 1; padding: 8px 12px 10px; background: none; border: 0; color: #8a8799;
  font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab-bar button:hover { color: var(--primary); }
.tab-bar button.active { color: var(--primary); border-bottom-color: var(--primary); }

.scope-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.scope-bar[hidden] { display: none; }
.scope-label { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.scope-bar select { flex: 1; min-width: 0; min-height: 32px; font-size: 12px; padding: 4px 8px; }

.level-list { flex: 1; overflow-y: auto; padding: 8px; }
.list-note { padding: 18px; text-align: center; color: var(--muted); font-size: 12.5px; }
.list-note.error { color: var(--red); }
.level-item { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; text-align: left; background: #fff; border: 1px solid transparent; border-radius: 9px;
  padding: 9px 11px; margin-bottom: 4px; cursor: pointer; }
.level-item:hover { background: #f8f7fc; border-color: var(--line); }
.level-item.active { background: var(--primary-soft); border-color: #d9ccf3; }
.level-item .name { font-size: 12.5px; font-weight: 600; color: #51465f; }
.level-item .meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.level-item .meta.broken { color: var(--red); }
.level-item .right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.order-badge { font-size: 10px; color: var(--primary); background: var(--primary-soft); border-radius: 20px; padding: 1px 7px; }
.level-item .version { font-size: 9.5px; color: #b6b2c2; font-family: ui-monospace, Consolas, monospace; }

/* ── Editor pane ───────────────────────────────────────────────────── */
.editor-header { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line); }
.level-title { font-size: 16px; font-weight: 700; color: var(--ink); }
.level-id { font-size: 11.5px; color: var(--muted); margin-top: 2px; font-family: ui-monospace, Consolas, monospace; }
.editor-actions { display: flex; align-items: center; gap: 8px; }
.unsaved-badge { font-size: 10px; font-weight: 600; color: var(--amber); background: #fdf1dc; border-radius: 20px; padding: 3px 9px; }
.scope-badge { font-size: 10px; font-weight: 700; color: var(--primary); background: var(--primary-soft);
  border: 1px solid #d9ccf3; border-radius: 20px; padding: 3px 9px; text-transform: uppercase; letter-spacing: 0.4px; }
.scope-badge[hidden] { display: none; }

.editor-body { flex: 1; overflow: auto; padding: 18px 20px; }
/* With a loaded level, JSON on the left and the Preview panel on the side. */
.editor-body:has(.editor-json) { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; }
.empty-state { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); }
.empty-state .icon { font-size: 40px; }
.empty-state .text { font-size: 14px; } .empty-state .text.error { color: var(--red); } .empty-state .sub { font-size: 12px; color: #b6b2c2; }

.editor-body .editor-json { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.editor-body textarea { width: 100%; min-height: 440px; resize: vertical; font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px; line-height: 1.6; background: #fbfaff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.issues { border-radius: 10px; padding: 11px 13px; font-size: 12px; }
.issues[hidden] { display: none; }
.issues-title { font-weight: 700; margin-bottom: 5px; }
.issues ul { margin: 0; padding-left: 18px; }
.issues.error { background: #fdeef0; color: #b23b48; border: 1px solid #f5d6db; }
.issues.warn { background: #fff6e8; color: #9a6a1c; border: 1px solid #f0dcbb; }

/* Preview as a side panel (sticky so it stays in view while the JSON scrolls). */
.editor-preview { position: sticky; top: 0; background: #faf9fe; border: 1px solid var(--line);
  border-radius: 12px; padding: 16px; }
.editor-preview h3 { font-size: 13px; font-weight: 700; margin-bottom: 14px; }
.preview-field { margin-bottom: 11px; }
.preview-field label { display: block; font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.preview-field .value { font-size: 14px; font-weight: 600; color: var(--ink); margin-top: 2px; }
.preview-section { margin-top: 14px; }
.preview-section label { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.preview-grid { display: grid; gap: 3px; margin-top: 8px; max-width: 260px; }
.preview-grid .cell { aspect-ratio: 1; border-radius: 5px; display: grid; place-items: center; font-size: 15px; }
.preview-grid .cell.clue { outline: 2px solid #f5c04a; outline-offset: -2px; }

/* ── Modals ────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(42,30,74,0.35); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 10000; }
.modal-overlay[hidden] { display: none; }
#importModal, #assignModal, #newSetModal { z-index: 10010; }
#confirmModal { z-index: 10020; }
.modal { width: 100%; max-width: 440px; background: #fff; border: 1px solid var(--line);
  border-radius: 16px; padding: 24px; box-shadow: 0 30px 80px rgba(42,31,74,0.22); }
.modal.modal-wide { max-width: 560px; }
.modal h2 { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.modal p { font-size: 12.5px; color: var(--muted); line-height: 1.6; margin-bottom: 14px; }
.modal code { background: var(--surface-soft); color: var(--primary); border-radius: 4px; padding: 1px 5px; font-size: 11.5px; }
.modal input { width: 100%; margin-bottom: 14px; min-height: 38px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-fields { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.modal-fields label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.modal-fields input, .modal-fields select { width: 100%; margin-bottom: 8px; }
.field-hint { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); font-size: 10px; }
#newLevelIdRow[hidden] { display: none; }

/* import */
.import-hint { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin: 2px 0 0; }
.import-check { display: flex; align-items: flex-start; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--ink); cursor: pointer; text-transform: none; letter-spacing: 0; font-weight: 400; }
.import-check input { width: auto; margin: 2px 0 0; accent-color: var(--primary); }
.import-result { margin-bottom: 16px; max-height: 320px; overflow-y: auto; border-top: 1px solid var(--line); padding-top: 12px; }
.import-result[hidden] { display: none; }
.import-summary { font-size: 13px; font-weight: 700; padding: 8px 10px; border-radius: 8px; margin-bottom: 10px; }
.import-summary.ok { color: var(--green); background: #e8f6ee; } .import-summary.warn { color: var(--amber); background: #fdf3e2; }
.import-list-title { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; margin: 10px 0 6px; }
.import-fail-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.import-fail-list li { background: #fdeef0; border: 1px solid #f5d6db; border-radius: 8px; padding: 7px 10px; }
.import-fail-name { font-size: 12px; font-weight: 600; color: var(--ink); }
.import-fail-why { font-size: 11.5px; color: #b23b48; line-height: 1.5; margin-top: 2px; }

/* export / assign / sets lists */
.export-radio { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink); cursor: pointer; text-transform: none; letter-spacing: 0; font-weight: 400; margin-bottom: 2px; }
.export-radio input { width: auto; margin: 0; accent-color: var(--primary); }
.export-selection { margin-bottom: 16px; }
.export-select-tools { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.export-sel-count { font-size: 11.5px; color: var(--muted); margin-left: auto; }
.export-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 4px; }
.export-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.export-item:hover { background: #f8f7fc; }
.export-item input { width: auto; margin: 0; accent-color: var(--primary); }
.export-item-name { font-size: 12.5px; color: var(--ink); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.export-item-id { font-size: 11px; color: var(--muted); font-family: ui-monospace, Consolas, monospace; }

/* sets manager */
.sets-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.sets-bar label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.sets-bar select { flex: 1; min-width: 120px; }
.sets-api-hint { font-family: ui-monospace, Consolas, monospace; font-size: 11px; color: var(--muted);
  background: var(--surface-soft); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin-bottom: 12px; overflow-x: auto; white-space: nowrap; }
.sets-api-hint[hidden] { display: none; }
.sets-body[hidden] { display: none; }
.sets-tools { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.sets-tools .export-sel-count { margin-left: auto; }

@media (max-width: 1200px) {
  /* Narrow editor pane: stack JSON over the preview again. */
  .editor-body:has(.editor-json) { grid-template-columns: 1fr; }
  .editor-preview { position: static; }
}
@media (max-width: 900px) {
  .editor-split { grid-template-columns: 1fr; height: auto; }
  .lvpane { height: 60vh; } .editor { min-height: 70vh; }
}
