/* ── Editor Layout ──────────────────────────── */
.editor-layout {
  display: grid;
  grid-template-columns: var(--panel-width) 1fr var(--panel-width);
  grid-template-rows: auto var(--toolbar-height) 1fr;
  height: 100vh;
  overflow: hidden;
}

.editor-header {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--spacing-lg);
  background: var(--bg-surface);
  border-bottom: var(--accent) dashed 3px;
  box-shadow: var(--shadow-md);
  z-index: 100;
  min-height: 40px;
}
.editor-header-left { display: flex; align-items: center; gap: var(--spacing-lg); }
.editor-logo { font-size: var(--fs-lg); font-weight: 700; color: var(--accent); letter-spacing: -0.02em; }
.editor-page-name {
  padding: 4px 10px; background: var(--bg-input); border: 1px solid lightgray;
  border-radius: var(--radius-md); font-size: var(--fs-sm); color: var(--text-dark);
  min-width: 200px;
}
.editor-page-name:focus { border: 1px dashed var(--accent); }
.editor-header-right { display: flex; align-items: center; gap: var(--spacing-sm); }

.editor-toolbar {
  grid-column: 1 / -1;
  z-index: 90;
}

/* ── Left Panel: Layers ─────────────────────── */
.layers-panel {
  grid-row: 3;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.layers-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.layers-panel-header h4 { font-size: var(--fs-sm); color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
.layers-list {
  flex: 1; overflow-y: auto;
  padding: var(--spacing-sm);
  list-style: none; margin: 0;
}
.layers-list ul.layer-children {
  list-style: none; margin: 0; padding: 0 0 0 16px;
}

/* ── Layer Item ─────────────────────────────── */
.layer-item { list-style: none; }
.layer-row {
  display: flex; align-items: center; gap: var(--spacing-sm);
  padding: 6px 8px; border-radius: var(--radius-md);
  font-size: var(--fs-sm); cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}
.layer-row:hover { background: var(--bg-surface-hover); box-shadow: var(--shadow-inset); }
.layer-row.selected { background: var(--accent); color: var(--text-on-accent); border-color: var(--accent); }
.layer-item.dragging { opacity: 0.4; }
.layer-item.drop-target > .layer-row { border: 1px dashed var(--accent); background: var(--accent-subtle); }
.layer-drop-indicator { height: 2px; background: var(--accent); border-radius: 1px; margin: 2px 0; }
.layer-row .layer-icon { width: 18px; color: var(--text-muted); text-align: center; flex-shrink: 0; }
.layer-row .layer-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-row .layer-id { font-size: var(--fs-xs); color: var(--text-muted); font-family: var(--font-mono); }
.layer-row .layer-visibility { color: var(--text-muted); font-size: var(--fs-xs); }
.layer-row .layer-visibility:hover { color: var(--text-dark); }

/* ── Canvas Area ────────────────────────────── */
.canvas-area {
  grid-row: 3;
  background: #e8e8e8;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--spacing-2xl);
  position: relative;
}
.canvas-wrapper {
  position: relative;
  background: var(--bg-canvas);
  box-shadow: var(--shadow-lg);
  border: 1px solid lightgray;
  min-height: 600px;
  transition: width var(--transition-normal);
}
.canvas-zoom-controls {
  position: absolute; bottom: 16px; left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--spacing-sm);
  padding: 4px 8px;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  z-index: 50;
}
.canvas-zoom-controls .zoom-label { font-size: var(--fs-xs); color: var(--text-secondary); min-width: 36px; text-align: center; }

/* ── Widget on Canvas ───────────────────────── */
.widget {
  position: relative;
  float: left;
  border: 1px solid transparent;
  cursor: move;
  transition: border var(--transition-fast);
  overflow: visible;
}
.widget:hover { border: 1px dashed var(--accent); }
.widget.selected { border: 1px dashed var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.widget-label {
  position: absolute; top: -20px; left: 0;
  font-size: 10px; color: var(--text-on-accent);
  background: var(--accent);
  padding: 1px 6px; border-radius: 3px 3px 0 0;
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity var(--transition-fast);
}
.widget:hover .widget-label,
.widget.selected .widget-label { opacity: 1; }

.widget-resize-handle {
  position: absolute; width: 8px; height: 8px;
  background: var(--accent); border: 1px solid var(--bg-canvas);
  border-radius: 1px; z-index: 10;
}
.widget-resize-handle.nw { top: -4px; left: -4px; cursor: nw-resize; }
.widget-resize-handle.ne { top: -4px; right: -4px; cursor: ne-resize; }
.widget-resize-handle.sw { bottom: -4px; left: -4px; cursor: sw-resize; }
.widget-resize-handle.se { bottom: -4px; right: -4px; cursor: se-resize; }
.widget-resize-handle.n { top: -4px; left: 50%; margin-left: -4px; cursor: n-resize; }
.widget-resize-handle.s { bottom: -4px; left: 50%; margin-left: -4px; cursor: s-resize; }
.widget-resize-handle.e { right: -4px; top: 50%; margin-top: -4px; cursor: e-resize; }
.widget-resize-handle.w { left: -4px; top: 50%; margin-top: -4px; cursor: w-resize; }

/* ── Right Panel: Settings ──────────────────── */
.settings-panel {
  grid-row: 3;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.settings-panel-header {
  display: flex; align-items: center;
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.settings-panel-header h4 {
  font-size: var(--fs-sm); color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.settings-sections {
  flex: 1; overflow-y: auto;
  padding: var(--spacing-sm);
}

/* ── Settings Section ───────────────────────── */
.settings-section {
  margin-bottom: var(--spacing-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.settings-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-surface-hover);
  font-size: var(--fs-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  cursor: pointer; user-select: none;
  border-bottom: 1px solid var(--border);
}
.settings-section-header:hover { background: #e8e8e8; }
.settings-section-body { padding: var(--spacing-sm) var(--spacing-md); }
.settings-section-body.collapsed { display: none; }

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-sm);
}
.settings-grid .field-full { grid-column: 1 / -1; }

/* ── Responsive breakpoint toggle ───────────── */
.breakpoint-bar {
  display: flex; align-items: center; gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-surface-hover);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.breakpoint-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: var(--radius-md);
  font-size: var(--fs-xs); color: var(--text-secondary);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}
.breakpoint-btn.active { background: var(--accent); color: var(--text-on-accent); border-color: var(--accent); }
.breakpoint-btn:hover { background: var(--bg-surface-hover); border: 1px dashed var(--accent); }
.breakpoint-label { font-size: var(--fs-xs); color: var(--text-muted); margin-left: auto; }

/* ── Empty state ────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--spacing-2xl); color: var(--text-muted); text-align: center;
}
.empty-state-icon { font-size: 2rem; margin-bottom: var(--spacing-md); opacity: 0.4; }
.empty-state-text { font-size: var(--fs-sm); }
