/* ── Reset & base ─────────────────────────────────────────────── */
*,*::before,*::after{box-sizing:border-box}
html,body{height:100%;overflow:hidden;margin:0;padding:0}
body{
  font-family:'Inter', sans-serif;
  background:#f8fafc;
  color:#0f172a;
  font-size:13px;
  line-height:1.4;
}

::-webkit-scrollbar{width:6px;height:6px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:#e2e8f0;border-radius:10px}
::-webkit-scrollbar-thumb:hover{background:#cbd5e1}

/* ── App shell ────────────────────────────────────────────────── */
#app{display:flex;flex-direction:column;height:100vh;width:100vw;background:#f8fafc}

/* ── Header ───────────────────────────────────────────────────── */
.app-header{
  display:flex;align-items:center;justify-content:space-between;
  padding:0 16px;height:56px;flex-shrink:0;z-index:200;
  background:#ffffff;border-bottom:1px solid #e2e8f0;
}
.logo{display:flex;align-items:center;gap:10px}
.logo-icon{
  width:32px;height:32px;border-radius:8px;
  background:linear-gradient(135deg,#4f46e5,#6366f1);
  display:flex;align-items:center;justify-content:center;
  color:#fff;font-size:16px;flex-shrink:0;
}
.logo-name{font-size:16px;font-weight:800;color:#0f172a;letter-spacing:-0.4px}
.logo-badge{
  font-size:9px;font-weight:700;color:#6366f1;
  background:#f5f3ff;border:1px solid #ddd6fe;
  padding:1px 8px;border-radius:5px;text-transform:uppercase;
}

.cloud-sync-status {
  font-size: 10px; font-weight: 800; color: #94a3b8;
  padding: 0 12px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center; transition: all 0.2s;
  cursor: default; user-select: none; text-transform: uppercase; letter-spacing: 0.5px;
  max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cloud-sync-status.local {
  background: #f8fafc; border: 1px solid #e2e8f0; color: #94a3b8;
}
.cloud-sync-status.pending {
  color: #6366f1; background: #f5f3ff; border: 1px solid #ddd6fe;
  cursor: pointer;
}
.cloud-sync-status.pending:hover {
  background: #ede9fe; border-color: #6366f1;
}

/* ── Toolbar controls ─────────────────────────────────────────── */
.tool-group{
  display:flex; align-items:center; background:#f1f5f9; border:1px solid #e2e8f0;
  border-radius:8px; padding:2px; gap:2px;
}
.tool-btn{
  border:none;background:transparent;color:#64748b;
  cursor:pointer;padding:6px 10px;border-radius:6px;
  font-size:13px;transition:all 0.1s;
}
.tool-btn:hover{background:#e2e8f0;color:#0f172a}
.tool-btn.active{background:#ffffff;color:#4f46e5;box-shadow:0 1px 4px rgba(0,0,0,0.06);font-weight:600}

.vd{width:1px;background:#e2e8f0;height:20px;margin:0 4px;flex-shrink:0}

/* Split Button */
.btn-group{display:inline-flex;overflow:hidden;border-radius:8px;box-shadow:0 2px 8px rgba(99,102,241,0.15)}
.btn-export{
  padding:8px 16px;background:linear-gradient(135deg,#4f46e5,#6366f1);
  color:#fff;border:none;font-size:13px;font-weight:700;
  cursor:pointer;transition:all 0.15s;
}

.btn-outline-sm{
  padding:8px 16px;background:#fff;color:#475569;
  border:1px solid #e2e8f0;border-radius:8px;font-size:12px;
  font-weight:700;cursor:pointer;transition:all 0.2s;
  display:inline-flex;align-items:center;white-space:nowrap;
}
.btn-outline-sm:hover{border-color:#6366f1;color:#6366f1;box-shadow:0 2px 8px rgba(99,102,241,0.08)}
.inline-create-form{display:flex;gap:8px;align-items:stretch}
.inline-create-form .field-input{flex:1;min-width:0}

/* IO Dropdown */
.io-dropdown{
  position:absolute;right:0;top:calc(100% + 6px);
  background:#fff;border:1px solid #e2e8f0;border-radius:12px;
  min-width:260px;z-index:500;box-shadow:0 12px 32px rgba(0,0,0,0.12);
  padding:6px 0;animation: slideIn 0.2s ease-out;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.io-lbl{padding:10px 16px 4px;font-size:10px;font-weight:800;color:#94a3b8;text-transform:uppercase;letter-spacing:1.5px}
.io-item{
  display:flex;align-items:center;gap:12px;padding:12px 16px;
  font-size:13px;font-weight:600;color:#334155;border:none;
  background:transparent;width:100%;text-align:left;cursor:pointer;
  transition: background 0.15s;
}
.io-item:hover{background:#f8fafc;color:#4f46e5}
.io-item i{font-size:14px;width:18px;text-align:center}

/* ── Body layout ──────────────────────────────────────────────── */
.app-body{display:flex;flex:1;overflow:hidden;background:#f8fafc}
.canvas-area{flex:1;display:flex;overflow:hidden;background:#f1f5f9}

/* ── Sidebar Tabs ─────────────────────────────────────────── */
.sidebar-tabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 0;
  height: 48px;
  flex-shrink: 0;
}
.sidebar-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0 12px;
  font-size: 10px;
  font-weight: 800;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
}
.sidebar-tab:hover {
  color: #64748b;
  background: #f8fafc;
}
.sidebar-tab.active {
  color: #6366f1;
  border-bottom-color: #6366f1;
  background: #fff;
}
.sidebar-tab i {
  font-size: 12px;
}
.sidebar-tab span {
  display: inline;
}

@media (max-width: 400px) {
  .sidebar-tab span { display: none; }
  .sidebar-tab i { font-size: 16px; }
}

.sidebar-info-banner {
  background: #f0f9ff;
  border: 1px solid #e0f2fe;
  color: #0369a1;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}
.sidebar-info-banner i {
  margin-top: 2px;
}

.empty-selection {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #94a3b8;
  padding-bottom: 60px;
}
.empty-selection i { font-size: 32px; opacity: 0.3; }
.empty-selection p { font-size: 13px; font-weight: 600; }

/* ── Left sidebar (components) ───────────────────────────────── */
/* ── Tree-Node Add Button ──────────────────────────────────── */
.tree-node-add{
  background:#f5f3ff; border:1px solid #ddd6fe; color:#6366f1; cursor:pointer;
  width:22px; height:22px; border-radius:6px;
  display:flex; align-items:center; justify-content:center;
  font-size:10px; transition:all 0.2s; margin-left:8px;
  box-shadow: 0 1px 3px rgba(99, 102, 241, 0.1);
}
.tree-node-add:hover{ background:#6366f1; color:#fff; border-color:#6366f1; transform:translateY(-1px); box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2); }
.tree-node-add i { font-size: 10px; }



/* ── Drag resize handles ────────────────────────────────────────── */
.resize-handle{width:6px;flex-shrink:0;cursor:col-resize;position:relative;z-index:100;user-select:none}
.resize-handle::after{content:'';position:absolute;top:0;bottom:0;left:50%;width:1px;transform:translateX(-50%);background:#e2e8f0;transition:all 0.1s}
.resize-handle:hover::after,.resize-handle.dragging::after{background:#6366f1;width:3px}

body.resizing-active * { cursor: col-resize !important; }
body.resizing-active iframe { pointer-events: none !important; }

/* ── Tree panel ───────────────────────────────────────────────── */
.tree-panel{background:#ffffff;border-right:1px solid #e2e8f0;display:flex;flex-direction:column;flex-shrink:0;overflow:hidden;min-width:240px}
.sidebar-title, .code-toolbar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  font-size: 10px;
  font-weight: 800;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  flex-shrink: 0;
}
.sidebar-title span, .code-toolbar span {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-title i, .code-toolbar i {
  font-size: 12px;
  color: #6366f1;
}

.code-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  overflow: hidden;
}
.code-content {
  flex: 1;
  overflow: hidden;
  background: #0f172a;
  padding: 0;
  display: flex;
}
.mjml-editor {
  flex: 1;
  background: transparent;
  color: #e2e8f0;
  border: none;
  border-radius: 0;
  padding: 24px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: none;
  outline: none;
}
.mjml-editor::placeholder { color: #475569; }

.btn-sync-code {
  background: #f5f3ff;
  color: #6366f1;
  border: 1px solid #ddd6fe;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
}
.btn-sync-code:hover {
  background: #6366f1;
  color: #fff;
  border-color: #6366f1;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}
.btn-sync-code i { font-size: 12px; }
.tree-scroll{position:relative;flex:1;overflow-y:auto;padding:6px}
.tree-node{position:relative;margin:1px 0}
.tree-node-row{
  display:flex;align-items:center;padding:4px 10px;border-radius:6px;

  cursor:pointer;border:1px solid transparent;transition:all 0.15s ease;gap:6px;
}
.tree-node-row:hover{background:#f8fafc;border-color:#e2e8f0}
.tree-node-row.selected{background:#f5f3ff;border-color:#c7d2fe;box-shadow:inset 4px 0 0 #6366f1}
.tree-node-children{padding-left:14px;border-left:1px dashed #e2e8f0;margin-left:14px;padding-top:1px;padding-bottom:2px;transition: all 0.2s}

.tree-node-type{font-size:11px;font-weight:800;color:#334155;font-family:'JetBrains Mono',monospace;flex:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;text-transform:uppercase;letter-spacing:0.5px}
.tree-node-row[data-type="mjml"] { background: #f8fafc; border-bottom: 1px solid #e2e8f0; border-radius: 0; padding-top: 8px; padding-bottom: 8px; cursor: default; }
.tree-node-row[data-type="mjml"] .tree-node-type { color: #6366f1; font-size: 10px; }
.tree-node-row[data-type="mj-head"], .tree-node-row[data-type="mj-body"] { background: #fff; font-style: normal; }
.tree-node-row[data-type="mj-head"] .tree-node-type, .tree-node-row[data-type="mj-body"] .tree-node-type { color: #475569; font-size: 10px; }

.tree-node-icon{font-size:13px;color:#a5b4fc;width:18px;text-align:center}
.node-classes{display:flex;gap:4px;margin-right:8px}
.node-class-tag{font-size:9px;font-weight:700;padding:0px 5px;border-radius:4px;background:#f5f3ff;color:#6366f1;border:1px solid #ddd6fe;font-family:'JetBrains Mono',monospace;max-width:80px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.class-badge-mini{font-size:10px;font-weight:700;padding:2px 6px;border-radius:4px;background:#f5f3ff;color:#6366f1;border:1px solid #ddd6fe;font-family:'JetBrains Mono',monospace}

.tree-node-toggle{
  font-size:10px; color:#cbd5e1; cursor:pointer; width:12px;
  display:flex; align-items:center; justify-content:center;
  transition: transform 0.2s;
}
.tree-node-toggle.collapsed { transform: rotate(-90deg); color: #6366f1; }
.tree-node-toggle:hover { color: #6366f1; }

.tree-node-delete{opacity:0.4; font-size:12px; color:#94a3b8; border:none; background:transparent; cursor:pointer; padding:6px; border-radius:6px; transition:all 0.15s}
.tree-node-row:hover .tree-node-delete,
.tree-node-row:hover .tree-node-add{opacity:1}
.tree-node-delete:hover{color:#ef4444;background:#fee2e2; opacity:1}
.tree-node-add{opacity:0.8; background:#f5f3ff; border:1px solid #ddd6fe; color:#6366f1; } 
.tree-node-copy{opacity:0.4; font-size:11px; color:#94a3b8; border:none; background:transparent; cursor:pointer; padding:6px; border-radius:6px; transition:all 0.15s; margin-left:4px}
.tree-node-row:hover .tree-node-copy{opacity:1}
.tree-node-copy:hover{color:#6366f1; background:#f5f3ff}
.tree-node-delete{margin-left:4px}





/* Dragging & Drop Indicators */
.drop-zone{min-height:20px;transition: all 0.2s;position:relative}

/* Highlight Parent on Drag */
body.dragging .drop-zone:hover { background: rgba(99,102,241,0.03); border-color: #6366f1 }
body.dragging .tree-node-children:hover { border-left-color: #6366f1; border-left-style: solid }

.drop-hint-area{
  margin-top:8px;padding:10px;border:1px dashed #e2e8f0;border-radius:10px;
  display:flex;flex-direction:column;align-items:center;gap:8px;transition:all 0.2s;
  position:relative;min-height:40px;justify-content:center;
}
.drop-hint-area:hover{border-color:#6366f1;background:rgba(99,102,241,0.02)}
.drop-here-label{font-size:10px;font-weight:700;color:#6366f1;text-transform:uppercase;opacity:0;pointer-events:none;position:absolute;transition:all 0.2s}
body.dragging .drop-here-label{opacity:0.6}
body.dragging .btn-add-inline{opacity:0.1;pointer-events:none}

/* Custom Add Component UI */
.custom-add-wrap{position:relative;width:100%;display:flex;justify-content:center}
.btn-add-inline{
  background:transparent;border:1px solid #e2e8f0;color:#64748b;
  font-size:11px;font-weight:700;padding:6px 14px;border-radius:100px;
  cursor:pointer;transition:all 0.2s;display:flex;align-items:center;
}
.btn-add-inline:hover{border-color:#6366f1;color:#6366f1;background:#fff}
.custom-add-menu{
  position:absolute;top:calc(100% + 4px);left:50%;transform:translateX(-50%);
  background:#fff;border:1px solid #e2e8f0;border-radius:12px;
  box-shadow:0 8px 32px rgba(0,0,0,0.15);width:200px;z-index:999;
  padding:6px;overflow:hidden;
}
.custom-add-label{padding:6px 10px;font-size:9px;font-weight:800;color:#94a3b8;text-transform:uppercase;letter-spacing:1px;border-bottom:1px solid #f1f5f9}
.custom-add-item{
  display:block;width:100%;padding:10px 12px;border:none;background:transparent;
  text-align:left;font-size:12px;font-weight:600;color:#475569;
  cursor:pointer;border-radius:8px;transition:all 0.1s;
}
.custom-add-item:hover{background:#f5f3ff;color:#4f46e5}

/* ── Preview panel ────────────────────────────────────────────── */
.preview-panel{flex:1;display:flex;flex-direction:column;overflow:hidden;background:#f1f5f9}
.preview-toolbar{display:flex;align-items:center;justify-content:space-between;padding:10px 16px;background:#ffffff;border-bottom:1px solid #e2e8f0}
.preview-frame-wrap{flex:1;overflow:auto;display:flex;align-items:flex-start;justify-content:center;padding:0;position:relative}
.preview-device{border-radius:0;overflow:hidden;box-shadow:0 15px 35px -8px rgba(0,0,0,0.15);transition:width 0.4s cubic-bezier(0.4,0,0.2,1);background:#fff}
.preview-device.full-width{width:100% !important;border-radius:0}
.preview-frame{width:100%;min-height:600px;border:none;display:block}

/* ── Right sidebar (inspector) ────────────────────────────────── */
.sidebar-right{width:500px;background:#ffffff;border-left:1px solid #e2e8f0;display:flex;flex-direction:column;flex-shrink:0;min-width:500px}
.inspector-body{flex:1;overflow-y:auto;padding:14px 16px}

/* Selection Header Redesign */
.node-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:16px;background:#f8fafc;padding:8px 12px;border-radius:10px;border:1px solid #e2e8f0}
.node-header-info{display:flex;align-items:center;gap:10px}
.node-header-icon{width:28px;height:28px;background:#fff;border:1px solid #e2e8f0;border-radius:6px;display:flex;align-items:center;justify-content:center;color:#6366f1;font-size:14px}
.node-header-badge{font-size:12px;font-weight:800;color:#1e293b;font-family:'JetBrains Mono',monospace;text-transform:uppercase}
.node-header-id{font-size:10px;color:#94a3b8;font-family:'JetBrains Mono',monospace;background:#fff;padding:1px 6px;border-radius:5px;border:1px solid #f1f5f9}

.inspector-section{margin-bottom:16px}
.inspector-section-label{font-size:10px;font-weight:800;color:#94a3b8;text-transform:uppercase;letter-spacing:1.5px;display:flex;align-items:center;gap:8px;margin-bottom:10px}
.inspector-section-label::after{content:'';flex:1;height:1px;background:#f1f5f9}
.inspector-section-label.sub { grid-column: span 2; margin-top: 14px; width: 100%; }
.inspector-section-label.sub:first-child { margin-top: 0; }

/* Fields */
.field-group{margin-bottom:12px}
.field-label{font-size:11px;font-weight:700;color:#64748b;text-transform:uppercase;letter-spacing:0.5px;margin-bottom:4px;display:flex;align-items:center;gap:6px}
.field-input, .prop-val{width:100%;background:#f8fafc;border:1px solid #e2e8f0;border-radius:8px;padding:6px 12px;font-size:13px;color:#0f172a;font-family:'JetBrains Mono',monospace;outline:none;transition: all 0.2s}
.field-input:focus, .prop-val:focus{border-color:#6366f1;box-shadow:0 0 0 4px rgba(99,102,241,0.08);background:#fff}
.field-select{width:100%;appearance:none;background:#f8fafc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;border:1px solid #e2e8f0;border-radius:8px;padding:6px 32px 6px 12px;font-size:13px;color:#334155;font-family:'JetBrains Mono',monospace;outline:none;cursor:pointer}

/* Class Tags */
.class-badges{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:12px}
.class-badge{display:inline-flex;align-items:center;background:#f5f3ff;border:1px solid #ddd6fe;border-radius:100px;overflow:hidden;transition: all 0.2s}
.class-badge:hover{transform:translateY(-1px);box-shadow:0 4px 12px rgba(99,102,241,0.1)}
.class-badge .badge-text{padding:4px 12px;font-size:11px;font-weight:700;color:#6366f1;font-family:'JetBrains Mono',monospace;cursor:pointer}
.class-badge-rm{border:none;background:rgba(239,68,68,0.08);color:#ef4444;padding:4px 8px;cursor:pointer;font-size:11px;border-left:1px solid #ddd6fe;transition: all 0.15s}
.class-badge-rm:hover{background:#ef4444;color:#fff}

/* Modern Class Cards */
.cls-card-modern{border:1px solid #e2e8f0;border-radius:12px;margin-bottom:10px;overflow:hidden;background:#fff;transition:all 0.2s}
.cls-card-modern.open{border-color:#6366f1;box-shadow:0 4px 16px rgba(99,102,241,0.1)}
.cls-card-header{padding:8px 12px;background:#f8fafc;cursor:pointer;display:flex;align-items:center;justify-content:space-between;transition:all 0.15s}
.cls-card-title{font-size:13px;font-weight:800;color:#4f46e5;font-family:'JetBrains Mono',monospace}

/* Props */
.prop-row{display:flex;align-items:center;gap:8px;margin-bottom:8px}
.prop-key{font-family:'JetBrains Mono',monospace;font-size:11px;color:#64748b;width:130px;flex-shrink:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.prop-del{background:none;border:none;color:#cbd5e1;cursor:pointer;padding:8px;font-size:13px;transition:all 0.15s}
.prop-del:hover{color:#ef4444}

/* Dark View Styling */
.dark-section {
  background: #1e293b;
  border-radius: 12px;
  padding: 12px;
  margin-top: 8px;
  border: 1px solid rgba(255,255,255,0.05);
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.2);
}
.dark-section .prop-category {
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.1);
}
.dark-section .prop-category-header {
  background: rgba(255,255,255,0.02);
}
.dark-section .prop-category-header:hover {
  background: rgba(255,255,255,0.04);
}
.dark-section .prop-category-title {
  color: #cbd5e1;
}
.dark-section .prop-control-label {
  color: #94a3b8;
}
.dark-section .prop-val, .dark-section .field-select, .dark-section .field-input {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.1);
  color: #fff;
}
.dark-section .prop-slider::-webkit-slider-runnable-track {
  background: rgba(255,255,255,0.1);
}
.dark-section .prop-slider-val {
  background: rgba(99,102,241,0.2);
  color: #a5b4fc;
}

/* RTE */
.rte-wrap{margin-bottom:16px;position:relative}
.rte-bar{
  display:flex;gap:4px;padding:6px;background:#f8fafc;
  border:1px solid #e2e8f0;border-bottom:none;border-radius:12px 12px 0 0;
  box-shadow:inset 0 1px 2px rgba(0,0,0,0.02);
}
.rte-btn{
  border:1px solid transparent;background:transparent;color:#475569;
  width:32px;height:32px;border-radius:8px;font-size:13px;
  cursor:pointer;display:flex;align-items:center;justify-content:center;
  transition:all 0.15s ease;
}
.rte-btn:hover{background:#fff;border-color:#e2e8f0;color:#4f46e5;box-shadow:0 2px 4px rgba(0,0,0,0.05)}
.rte-btn.active{background:#4f46e5;color:#fff;border-color:#4338ca;box-shadow:0 2px 8px rgba(79,70,229,0.25)}
.rte-btn i{font-size:12px}

.rte-editor{
  min-height:140px;max-height:400px;border:1px solid #e2e8f0;
  border-radius:0 0 12px 12px;padding:16px;font-size:14px;
  line-height:1.6;background:#fff;outline:none;overflow-y:auto;
}
.rte-editor:focus{border-color:#6366f1;box-shadow:0 0 0 4px rgba(99,102,241,0.08)}

/* Link Popup */
.link-popup{
  position:absolute;top:50px;left:10px;right:10px;
  background:#fff;border:1px solid #e2e8f0;border-radius:14px;
  box-shadow:0 12px 36px rgba(0,0,0,0.18);z-index:500;padding:16px;
  animation: slideDown 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* Toast */
.toast-msg {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  background: #1e293b;
  color: #fff;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  z-index: 3000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  width: max-content;
  max-width: 90vw;
}
.toast-msg.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.toast-msg.ok {
  background: #059669;
}

/* ── Visual Property Editor Compact ────────────────────────────── */
.visual-editor-compact { display: flex; flex-direction: column; gap: 4px; }
.prop-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  column-gap: 12px;
  row-gap: 0;
}

.prop-item-compact {
  display: flex; flex-direction: column; align-items: stretch; gap: 4px;
  padding: 8px 0; border-bottom: 1px solid #f1f5f9;
  min-width: 0;
  transition: all 0.2s;
}

.prop-item-full {
  grid-column: span 2;
}
.prop-item-compact:last-child { border-bottom: none; }

.prop-item-compact.has-value {
  border: 1px solid #6366f1;
  background: #f8fafc;
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 4px;
}
.prop-item-compact.has-value:last-child {
  border-bottom: 1px solid #6366f1;
}

.prop-item-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 700; color: #64748b;
  text-transform: capitalize;
}
.prop-item-label i { width: 14px; text-align: center; color: #94a3b8; font-size: 10px; }
.prop-item-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.prop-item-controls { display: flex; align-items: center; gap: 4px; width: 100%; }

.w-100 { width: 100% !important; }

.prop-input-mini, .prop-select-mini {
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px;
  padding: 2px 6px; font-size: 11px; font-family: 'JetBrains Mono', monospace;
  color: #0f172a; outline: none; height: 24px; transition: all 0.2s;
}
.prop-input-mini:focus, .prop-select-mini:focus {
  border-color: #6366f1; background: #fff; box-shadow: 0 0 0 2px rgba(99,102,241,0.05);
}

.unit-input-group { display: flex; align-items: center; width: 100%; }

.color-compact { display: flex; align-items: center; gap: 4px; width: 100%; }
.color-compact .prop-input-mini { flex: 1; }
.color-swatch-mini {
  width: 20px; height: 20px; border-radius: 4px; border: 1px solid #e2e8f0;
  cursor: pointer; position: relative; overflow: hidden; flex-shrink: 0;
}
.color-swatch-mini input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

.sides-toggle-btn {
  background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 6px;
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  color: #94a3b8; cursor: pointer; transition: all 0.2s; margin-left: 4px;
}
.sides-toggle-btn.active { background: #6366f1; color: #fff; border-color: #6366f1; }
.sides-toggle-btn i { font-size: 10px; }

.sides-input-grid { 
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; 
  margin-top: 6px; width: 100%;
}
.side-input-box { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.side-mini-label { font-size: 8px; font-weight: 800; color: #cbd5e1; }

.advanced-mini { margin-top: 8px; padding-top: 8px; border-top: 1px dashed #e2e8f0; }
.add-prop-mini { margin-top: 4px; }
.add-prop-inline { margin-bottom: 8px; }
.add-prop-inline .prop-select-mini {
  width: 100%; border: 1px dashed #cbd5e1; background: #fff;
  color: #64748b; font-weight: 700; cursor: pointer;
  text-align: center; height: 32px; border-radius: 8px;
}
.add-prop-inline .prop-select-mini:hover { border-color: #6366f1; color: #6366f1; background: #f5f3ff; }
.prop-del-mini { background: none; border: none; color: #cbd5e1; cursor: pointer; padding: 2px; font-size: 11px; }
.prop-del-mini:hover { color: #ef4444; }

/* ── Theme Accordion ────────────────────────────────────────── */
.theme-accordion { border: 1px solid #e2e8f0; border-radius: 10px; overflow: hidden; margin-top: 4px; }
.theme-segment { border-bottom: 1px solid #e2e8f0; }
.theme-segment:last-child { border-bottom: none; }
.theme-segment-hdr {
  padding: 8px 12px; background: #f8fafc; font-size: 10px; font-weight: 800;
  color: #64748b; text-transform: uppercase; letter-spacing: 0.5px;
  cursor: pointer; display: flex; align-items: center; transition: all 0.2s;
}
.theme-segment-hdr:hover { background: #f1f5f9; color: #334155; }
.theme-segment.active .theme-segment-hdr { background: #fff; color: #6366f1; }
.theme-segment-body { padding: 10px; background: #fff; }

.theme-segment.active .theme-segment-hdr i.fa-sun { color: #f59e0b; }
.theme-segment.active .theme-segment-hdr i.fa-moon { color: #6366f1; }

/* ── Modals & Overlays ────────────────────────────────────────── */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; animation: fadeInModal 0.3s ease-out;
}
@keyframes fadeInModal { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: #ffffff; border-radius: 20px; width: 90%; max-width: 500px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden; animation: slideUpModal 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex; flex-direction: column;
}
@keyframes slideUpModal { from { opacity: 0; transform: translateY(20px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

.modal-sm { max-width: 420px; }
.modal-hdr { padding: 24px 24px 16px; display: flex; align-items: center; justify-content: space-between; }
.modal-hdr-title { font-size: 18px; font-weight: 800; color: #0f172a; letter-spacing: -0.5px; display: flex; align-items: center; gap: 12px; }
.modal-ftr { padding: 16px 24px 24px; display: flex; align-items: center; gap: 12px; background: #f8fafc; border-top: 1px solid #f1f5f9; }

/* Welcome Screen Specifics */
.welcome-box { max-width: 600px; padding: 40px; text-align: center; }
.welcome-logo { 
  width: 64px; height: 64px; background: linear-gradient(135deg, #4f46e5, #6366f1); 
  border-radius: 16px; display: flex; align-items: center; justify-content: center; 
  color: #fff; font-size: 32px; margin: 0 auto 24px; box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}
.welcome-title { font-size: 28px; font-weight: 800; color: #0f172a; margin-bottom: 12px; letter-spacing: -1px; }
.welcome-subtitle { font-size: 15px; color: #64748b; margin-bottom: 32px; line-height: 1.6; }

.welcome-actions { display: grid; grid-template-columns: 1fr; gap: 12px; }
.welcome-btn {
  display: flex; align-items: center; gap: 16px; padding: 16px 20px;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  text-align: left; cursor: pointer; transition: all 0.2s;
}
.welcome-btn:hover { border-color: #6366f1; background: #f5f3ff; transform: translateY(-2px); box-shadow: 0 8px 20px rgba(99, 102, 241, 0.08); }
.welcome-btn.primary { background: #f5f3ff; border-color: #ddd6fe; }
.welcome-btn.primary:hover { background: #ede9fe; border-color: #6366f1; }

.welcome-btn-icon { 
  width: 40px; height: 40px; border-radius: 10px; background: #f1f5f9; 
  display: flex; align-items: center; justify-content: center; font-size: 18px; color: #6366f1;
}
.welcome-btn.primary .welcome-btn-icon { background: #fff; }
.welcome-btn-text { flex: 1; }
.welcome-btn-name { display: block; font-size: 14px; font-weight: 700; color: #1e293b; margin-bottom: 2px; }
.welcome-btn-desc { display: block; font-size: 12px; color: #64748b; }

/* Confirmation Modals */
.confirm-box { padding: 32px; text-align: center; }
.confirm-icon { 
  width: 56px; height: 56px; background: #fee2e2; color: #ef4444; 
  border-radius: 50%; display: flex; align-items: center; justify-content: center; 
  font-size: 24px; margin: 0 auto 20px; 
}
.confirm-title { font-size: 20px; font-weight: 800; color: #0f172a; margin-bottom: 12px; }
.confirm-text { font-size: 14px; color: #64748b; margin-bottom: 24px; line-height: 1.5; }
/* ── Add Block Popup ────────────────────────────────────────── */
.add-block-box {
  background: #ffffff; border-radius: 24px; width: 90%; max-width: 800px;
  height: 540px; display: flex; overflow: hidden;
  box-shadow: 0 40px 100px -20px rgba(15, 23, 42, 0.35);
  border: 1px solid rgba(255,255,255,0.2);
}

.add-block-list-side {
  width: 320px; border-right: 1px solid #f1f5f9; 
  display: flex; flex-direction: column; background: #fff;
}
.add-block-detail-side {
  flex: 1; background: #f8fafc; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 40px; text-align: center;
}

.add-block-list-hdr { padding: 24px 24px 12px; }
.add-block-list-title { font-size: 18px; font-weight: 800; color: #0f172a; letter-spacing: -0.5px; margin-bottom: 2px; }
.add-block-list-sub { font-size: 11px; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: 1px; }

.add-block-tabs { display: flex; gap: 4px; background: #f1f5f9; padding: 4px; border-radius: 10px; margin-top: 12px; }
.add-block-tab { 
  flex: 1; border: none; background: transparent; padding: 6px 12px; font-size: 12px; font-weight: 700;
  color: #64748b; border-radius: 6px; cursor: pointer; transition: all 0.2s;
}
.add-block-tab.active { background: #fff; color: #6366f1; box-shadow: 0 2px 6px rgba(0,0,0,0.05); }

.add-block-list-scroll { flex: 1; overflow-y: auto; padding: 12px; }

.add-block-cat-label { font-size: 10px; font-weight: 800; color: #6366f1; text-transform: uppercase; letter-spacing: 1.5px; padding: 12px 12px 6px; }

.add-block-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-radius: 12px; cursor: pointer; transition: all 0.2s; border: 1px solid transparent;
}
.add-block-item:hover, .add-block-item.active {
  background: #f5f3ff; border-color: #ddd6fe;
}
.add-block-item-icon {
  width: 36px; height: 36px; background: #fff; border: 1px solid #e2e8f0;
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  color: #6366f1; font-size: 16px; transition: all 0.2s;
}
.add-block-item:hover .add-block-item-icon, .add-block-item.active .add-block-item-icon {
  background: #6366f1; color: #fff; border-color: #6366f1; scale: 1.05;
}
.add-block-item-name { font-size: 14px; font-weight: 700; color: #334155; }

.detail-icon-big {
  width: 80px; height: 80px; background: #fff; border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: #6366f1; margin-bottom: 24px;
  box-shadow: 0 10px 25px rgba(99, 102, 241, 0.15);
}
.detail-title { font-size: 24px; font-weight: 800; color: #0f172a; margin-bottom: 8px; letter-spacing: -1px; }
.detail-desc { font-size: 15px; color: #64748b; line-height: 1.6; margin-bottom: 32px; max-width: 340px; }
.detail-btn-add {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff; border: none; padding: 14px 40px; border-radius: 14px;
  font-size: 14px; font-weight: 700; cursor: pointer;
  box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
  transition: all 0.2s;
}
.detail-btn-add:hover { transform: translateY(-2px); box-shadow: 0 15px 30px rgba(99, 102, 241, 0.4); }
.detail-btn-add:active { transform: translateY(0); }

/* Gallery Preview */
.gallery-preview-wrap {
  width: 100%;
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.gallery-preview-lbl {
  font-size: 10px;
  font-weight: 800;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}
.gallery-preview-frame-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  position: relative;
}
.gallery-preview-frame {
  width: 300%; /* Scale up significantly to see the section proportionate to a realistic email width */
  height: 300%;
  border: none;
  transform: scale(0.33);
  transform-origin: top left;
}
.gallery-preview-placeholder {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #f1f5f9;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
}

