.editor-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: var(--bg);
  display: none; flex-direction: column;
}
.editor-overlay.open { display: flex; }

.editor-shell { display: flex; flex-direction: column; height: 100vh; }

.editor-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.editor-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 16px; }
.editor-topbar-actions { display: flex; gap: 8px; }

.ed-btn {
  padding: 8px 16px; border-radius: 9px; border: 1.5px solid var(--border);
  background: var(--surface2); font-size: 13px; font-weight: 500;
  cursor: pointer; color: var(--text2); font-family: 'DM Sans', sans-serif;
  transition: var(--transition);
}
.ed-btn:hover { background: var(--bg2); color: var(--text); }
.ed-btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.ed-btn.primary:hover { opacity: 0.88; }
.ed-btn.danger { background: transparent; border-color: #EF4444; color: #EF4444; }
.ed-btn.danger:hover { background: #FEF2F2; }

.editor-body {
  display: flex; flex: 1; overflow: hidden;
}

/* LEFT PANEL */
.editor-panel {
  width: 300px; flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.editor-panel-tabs {
  display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.ep-tab {
  flex: 1; padding: 12px 6px; font-size: 12px; font-weight: 600;
  border: none; background: none; cursor: pointer; color: var(--text3);
  font-family: 'DM Sans', sans-serif; border-bottom: 2px solid transparent;
  transition: var(--transition); margin-bottom: -1px;
}
.ep-tab:hover { color: var(--text); }
.ep-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.ep-tab-content { flex: 1; overflow-y: auto; padding: 16px; }
.ep-hint { font-size: 12px; color: var(--text3); margin-bottom: 16px; line-height: 1.5; }

/* COLOR SWATCHES */
.color-swatch-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: 10px; margin-bottom: 6px;
  background: var(--surface2); border: 1px solid var(--border);
  transition: var(--transition);
}
.color-swatch-row:hover { border-color: var(--text3); }
.color-swatch-left { display: flex; align-items: center; gap: 10px; }
.color-preview {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1.5px solid rgba(0,0,0,0.1); cursor: pointer;
  position: relative; overflow: hidden; flex-shrink: 0;
}
.color-preview input[type="color"] {
  position: absolute; inset: -6px; width: 150%; height: 150%;
  cursor: pointer; opacity: 0;
}
.color-swatch-label { font-size: 13px; font-weight: 500; color: var(--text); }
.color-swatch-hex { font-size: 11px; color: var(--text3); font-family: monospace; }
.color-swatch-count {
  font-size: 11px; color: var(--text3);
  background: var(--bg2); padding: 2px 7px; border-radius: 100px;
}

/* TEXT EDIT */
.text-edit-item {
  margin-bottom: 10px;
}
.text-edit-item label { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.8px; display: block; margin-bottom: 5px; }
.text-edit-item textarea, .text-edit-item input[type="text"] {
  width: 100%; padding: 9px 12px; border-radius: 9px;
  border: 1.5px solid var(--border); background: var(--surface2);
  font-family: 'DM Sans', sans-serif; font-size: 13px; color: var(--text);
  resize: vertical; outline: none; transition: border-color 0.2s;
}
.text-edit-item textarea:focus, .text-edit-item input:focus { border-color: var(--accent); }

/* LAYOUT FIELDS */
.ep-field { margin-bottom: 20px; }
.ep-field label { font-size: 12px; font-weight: 600; color: var(--text2); display: block; margin-bottom: 8px; }
.ep-field input[type="range"] { width: 100%; accent-color: var(--accent); }
.ep-val { font-size: 12px; color: var(--text3); font-family: monospace; display: block; margin-top: 4px; }

/* RAW CODE EDITOR */
.raw-editor {
  width: 100%; height: 420px; padding: 12px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 10px; font-family: 'Courier New', monospace;
  font-size: 12px; color: var(--text); resize: none; outline: none;
  line-height: 1.6; transition: border-color 0.2s;
}
.raw-editor:focus { border-color: var(--accent); }

/* RIGHT PREVIEW */
.editor-preview-wrap {
  flex: 1; display: flex; flex-direction: column;
  background: var(--bg2); overflow: hidden;
}
.editor-preview-toolbar {
  display: flex; gap: 8px; padding: 12px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.view-btn {
  padding: 7px 14px; border-radius: 8px; border: 1.5px solid var(--border);
  background: var(--surface2); font-size: 12px; font-weight: 500;
  cursor: pointer; color: var(--text2); font-family: 'DM Sans', sans-serif;
  transition: var(--transition);
}
.view-btn:hover { background: var(--bg2); }
.view-btn.active { background: var(--accent); border-color: var(--accent); color: white; }

.editor-preview-frame {
  flex: 1; display: flex; justify-content: center;
  align-items: flex-start; padding: 24px; overflow-y: auto;
}
.editor-preview-frame iframe {
  width: 100%; max-width: 600px; height: 100%;
  min-height: 600px; border: none; border-radius: 8px;
  box-shadow: 0 4px 40px rgba(0,0,0,0.15); background: white;
  transition: max-width 0.3s ease;
}