:root {
  --editor-bg: #f4f8fb;
  --editor-card: #ffffff;
  --editor-border: #dbe4ec;
  --editor-text: #1d3557;
  --editor-muted: #6b7f95;
  --editor-accent: #2ec4b6;
  --editor-accent-dark: #1d3557;
  --editor-danger: #e63946;
  --editor-shadow: 0 18px 44px rgba(29, 53, 87, 0.12);
}

html.editor-mode,
body.editor-mode {
  height: auto;
  min-height: 100%;
  overflow: auto;
  overflow-x: hidden;
  touch-action: pan-y;
  -webkit-user-select: text;
  user-select: text;
  overscroll-behavior: auto;
}

body.editor-mode {
  margin: 0;
  min-height: 100vh;
  background: var(--editor-bg);
  color: var(--editor-text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#editor-app,
#editor-shell {
  min-height: 100vh;
  height: auto;
  overflow: visible;
}

.hidden { display: none !important; }

#editor-pin-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

#editor-pin-card {
  width: min(440px, 94vw);
  background: var(--editor-card);
  border: 1px solid var(--editor-border);
  border-radius: 24px;
  box-shadow: var(--editor-shadow);
  padding: 28px;
  text-align: center;
}

#editor-pin-card h1,
#editor-head h1 {
  margin: 0;
  font-size: 28px;
}

#editor-pin-card p,
#editor-head p,
.editor-toolbar-note p {
  margin: 6px 0 0;
  color: var(--editor-muted);
  font-size: 13px;
}

#editor-pin-input {
  width: 160px;
  font-size: 28px;
  text-align: center;
  letter-spacing: 8px;
  padding: 10px;
  border: 2px solid var(--editor-border);
  border-radius: 12px;
  margin: 18px 0 10px;
}

#editor-pin-msg {
  min-height: 20px;
  color: var(--editor-danger);
  font-size: 13px;
}

#editor-pin-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 16px;
}

button,
.editor-button-link,
#editor-open-game {
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

button:active,
#editor-open-game:active {
  transform: scale(0.98);
}

#editor-pin-submit,
#editor-quiz-new,
#editor-host-new,
#editor-car-new,
.editor-save-btn {
  background: var(--editor-accent);
  color: #fff;
}

#editor-pin-back,
#editor-lock,
.editor-secondary-btn {
  background: #e6eef5;
  color: var(--editor-accent-dark);
}

#editor-shell {
  min-height: 100vh;
  padding: 18px;
}

#editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

#editor-head-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

#editor-open-game {
  background: var(--editor-accent-dark);
  color: #fff;
}

#editor-status {
  min-height: 22px;
  margin-bottom: 12px;
  color: #2a9d8f;
  font-size: 13px;
}

#editor-status.error {
  color: var(--editor-danger);
}

#editor-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.editor-tab {
  background: #fff;
  border: 1px solid var(--editor-border);
  color: var(--editor-muted);
}

.editor-tab.active {
  background: var(--editor-accent-dark);
  color: #fff;
  border-color: var(--editor-accent-dark);
}

.editor-pane {
  background: var(--editor-card);
  border: 1px solid var(--editor-border);
  border-radius: 20px;
  box-shadow: var(--editor-shadow);
  padding: 18px;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 16px;
}

.editor-toolbar-note {
  align-items: flex-start;
  justify-content: space-between;
}

.editor-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.editor-field span {
  font-size: 12px;
  font-weight: 700;
  color: var(--editor-muted);
}

.editor-field input,
.editor-field select,
.editor-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--editor-border);
  border-radius: 12px;
  font-size: 14px;
  background: #fff;
  color: var(--editor-text);
  box-sizing: border-box;
}

.editor-field textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.5;
}

.editor-field-grow {
  flex: 1 1 240px;
}

.editor-split {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.editor-list-wrap {
  background: #f8fbfd;
  border: 1px solid var(--editor-border);
  border-radius: 16px;
  padding: 12px;
  min-height: 320px;
  max-height: calc(100vh - 220px);
  overflow: auto;
}

#editor-quiz-count {
  font-size: 12px;
  color: var(--editor-muted);
  margin-bottom: 10px;
}

.editor-list-item {
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--editor-border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  color: var(--editor-text);
}

.editor-list-item-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.editor-list-thumb {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
  background: #fff;
  border: 1px solid var(--editor-border);
  border-radius: 8px;
  padding: 2px;
}

.editor-img-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid var(--editor-border);
  border-radius: 14px;
  padding: 10px;
  margin-bottom: 10px;
  min-height: 88px;
}

.editor-img-preview img {
  display: block;
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
}

.editor-img-preview--question {
  min-height: 160px;
  margin-top: 6px;
}

.editor-img-preview--question img {
  max-height: 320px;
}

.editor-quiz-content-block {
  padding: 12px;
  border: 1px solid var(--editor-border);
  border-radius: 14px;
  background: #f8fbfd;
}

.editor-quiz-content-block > span:first-child,
.editor-quiz-content-block > h3:first-child {
  display: block;
  margin: 0 0 8px;
  font-weight: 800;
  color: #1f2a37;
}

.editor-meta-divider {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--editor-border);
}

.editor-meta-divider h3 {
  margin: 0;
  font-size: 15px;
  color: var(--editor-muted);
}

.editor-img-preview--option img {
  max-height: 140px;
}

.editor-img-empty {
  color: var(--editor-muted);
  font-size: 13px;
}

.editor-img-preview.is-empty {
  background: #f8fbfd;
}

.editor-list-item.active {
  border-color: var(--editor-accent);
  box-shadow: 0 0 0 2px rgba(46, 196, 182, 0.12);
}

#editor-quiz-detail,
#editor-host-detail,
#editor-car-detail,
#editor-map-detail,
#editor-quest-detail {
  background: #fff;
  border: 1px solid var(--editor-border);
  border-radius: 16px;
  padding: 16px;
}

.editor-detail-empty {
  color: var(--editor-muted);
  font-size: 14px;
}

.editor-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.editor-detail-head h2 {
  margin: 0;
  font-size: 20px;
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.editor-grid .full {
  grid-column: 1 / -1;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.editor-danger-btn {
  background: var(--editor-danger);
  color: #fff;
}

.editor-option-grid {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--editor-border);
  border-radius: 14px;
  margin-bottom: 12px;
  background: #f8fbfd;
}

.editor-option-id {
  font-weight: 800;
  text-align: center;
  padding-top: 10px;
}

.editor-help {
  font-size: 12px;
  color: var(--editor-muted);
  margin-top: 6px;
}

.editor-list-source {
  display: block;
  margin-top: 4px;
  color: #2563eb;
  font-size: 11px;
  line-height: 1.35;
}

.editor-source-ref {
  border: 1px solid var(--editor-border);
  border-radius: 12px;
  padding: 12px 14px 14px;
  margin: 0;
}

.editor-source-ref legend {
  font-size: 13px;
  font-weight: 700;
  padding: 0 6px;
}

.editor-grid--source {
  margin-top: 8px;
}

.editor-json-preview {
  width: 100%;
  min-height: 220px;
  border: 1px solid var(--editor-border);
  border-radius: 12px;
  padding: 12px;
  background: #0f172a;
  color: #dbeafe;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  box-sizing: border-box;
  white-space: pre-wrap;
  overflow: auto;
}

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

.editor-inline-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--editor-border);
  border-radius: 14px;
  background: #f8fbfd;
}

@media (max-width: 1100px) {
  .editor-split {
    grid-template-columns: 1fr;
  }

  .editor-grid,
  .editor-inline-row {
    grid-template-columns: 1fr;
  }

  .editor-option-grid {
    grid-template-columns: 44px minmax(0, 1fr);
  }
}
