/* ==========================================================================
   Page Block Editor Styles
   ========================================================================== */

/* Layout */
.page-editor {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px);
    margin: -1.5rem;
    background: var(--bg-secondary, #f1f5f9);
}

/* Header */
.page-editor-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    min-height: 48px;
    flex-shrink: 0;
    z-index: 10;
}
.page-editor-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    flex-wrap: nowrap;
}
.page-action-separator {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 0.25rem;
}

/* Back button / title */
.pe-back-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.375rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
}
.pe-back-btn:hover {
    background: var(--gray-100);
    color: var(--text-dark);
}
.pe-title-area {
    flex: 0 1 auto;
    min-width: 0;
}
.pe-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}
.pe-title:hover { color: var(--primary); }
.pe-title-input {
    font-size: 1rem;
    font-weight: 600;
    border: 1px solid var(--primary);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    width: 200px;
    background: var(--card-bg);
    color: var(--text-dark);
}

/* Toolbar buttons */
.pe-tool-group {
    display: flex;
    gap: 2px;
    padding: 2px;
    background: var(--gray-100, #f3f4f6);
    border-radius: 6px;
}
.pe-tool-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted, #6b7280);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.pe-tool-btn:hover {
    background: var(--card-bg, #ffffff);
    color: var(--primary, #C8102E);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.pe-tool-btn:active {
    transform: scale(0.93);
}
.pe-tool-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.pe-lang-toggle .pe-tool-btn.active {
    background: #012169;
    color: white;
}
.pe-btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.375rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pe-btn-icon:hover { background: var(--gray-200, #e5e7eb); color: var(--text-dark); }
.pe-btn-icon:disabled { opacity: 0.35; cursor: default; }
.pe-btn-icon:disabled:hover { background: none; }
.pe-save-status {
    font-size: 0.75rem;
    color: var(--text-light);
    min-width: 40px;
}

/* Main content area */
.pe-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Canvas (scrollable center) */
.pe-canvas-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Prevent flex centering from clipping overflow top/bottom */
    justify-content: flex-start;
}
.pe-canvas-area > * {
    flex-shrink: 0;
}
.pe-canvas {
    width: 100%;
    max-width: 1200px;
    min-height: 400px;
    position: relative;
}

/* Block Palette (left sidebar) */
.pe-block-palette {
    width: 180px;
    flex-shrink: 0;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
    background: var(--card-bg);
    padding: 0.75rem 0.5rem;
}
.pe-palette-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0 0.375rem 0.5rem;
}
.pe-palette-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.pe-palette-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem;
    border: 1px solid transparent;
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-dark);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: grab;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    user-select: none;
}
.pe-palette-item:hover {
    border-color: var(--border-color);
    background: var(--gray-50, #f9fafb);
}
.pe-palette-item:active {
    cursor: grabbing;
}
.pe-palette-item svg {
    flex-shrink: 0;
    color: var(--text-muted);
}
/* SortableJS clone drag — keep the original visible */
.pe-palette-item.sortable-drag {
    opacity: 0.9;
    background: var(--card-bg);
    border: 1px solid var(--primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 6px;
}
.pe-palette-item.pe-palette-ghost {
    opacity: 0;
}
.pe-palette-item.pe-palette-chosen {
    background: rgba(200, 16, 46, 0.06);
    border-color: var(--primary);
}
/* Drop indicator on columns receiving palette drags */
.pe-column.sortable-drag-over {
    background: rgba(200, 16, 46, 0.03);
    outline: 2px dashed var(--primary);
    outline-offset: -2px;
    border-radius: 6px;
}
/* Toolbar btn style (reused for settings buttons elsewhere) */
.pe-block-toolbar-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-dark);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.pe-block-toolbar-btn:hover {
    border-color: var(--primary);
    background: var(--gray-50, #f9fafb);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.pe-block-toolbar-btn:active {
    transform: scale(0.97);
}
.pe-block-toolbar-btn svg {
    flex-shrink: 0;
}

/* ==========================================================================
   Sections
   ========================================================================== */
.pe-section {
    position: relative;
    margin-bottom: 1rem;
    border: 2px solid transparent;
    border-radius: 8px;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: #fff;
    min-height: 80px;
}
.pe-section:hover {
    border-color: var(--gray-300, #d1d5db);
}
.pe-section.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.12);
}

/* Section drag handle */
.pe-section-handle {
    position: absolute;
    top: 8px;
    left: -28px;
    width: 20px;
    height: 24px;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light, #9ca3af);
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}
.pe-section:hover .pe-section-handle,
.pe-section.selected .pe-section-handle {
    opacity: 1;
}
.pe-section-handle:hover {
    color: var(--text-dark);
    background: var(--gray-100);
}

/* Section header toolbar */
.pe-section-toolbar {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.5rem;
    background: var(--gray-50, #f9fafb);
    border-bottom: 1px solid var(--border-color);
    border-radius: 6px 6px 0 0;
    opacity: 0;
    transition: opacity 0.15s;
}
.pe-section:hover .pe-section-toolbar,
.pe-section.selected .pe-section-toolbar {
    opacity: 1;
}
.pe-section-toolbar-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.375rem;
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.pe-section-toolbar-btn:hover {
    background: var(--gray-200);
    color: var(--text-dark);
}
.pe-section-toolbar-btn.danger:hover {
    background: var(--danger-bg, #fee2e2);
    color: var(--danger-color, #dc2626);
}
.pe-section-toolbar-sep {
    width: 1px;
    height: 16px;
    background: var(--border-color);
    margin: 0 0.125rem;
}

/* Layout picker buttons in section toolbar */
.pe-layout-picker {
    display: flex;
    gap: 2px;
    margin-left: auto;
}
.pe-layout-btn {
    width: 28px;
    height: 22px;
    padding: 2px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--card-bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1px;
    transition: border-color 0.15s;
}
.pe-layout-btn:hover {
    border-color: var(--primary);
}
.pe-layout-btn.active {
    border-color: var(--primary);
    background: rgba(200, 16, 46, 0.06);
}
.pe-layout-col {
    background: var(--gray-300, #d1d5db);
    border-radius: 1px;
    height: 100%;
}
.pe-layout-btn.active .pe-layout-col {
    background: var(--primary);
}

/* Section content with columns */
.pe-section-content {
    padding: 20px;
    position: relative;
}
.pe-columns {
    display: flex;
    gap: 24px;
    min-height: 60px;
}
.pe-column {
    flex: 1;
    min-height: 40px;
    position: relative;
}
/* Layout column sizes */
.pe-columns[data-layout="sidebar-left"] .pe-column:first-child { flex: 1; }
.pe-columns[data-layout="sidebar-left"] .pe-column:last-child { flex: 2; }
.pe-columns[data-layout="sidebar-right"] .pe-column:first-child { flex: 2; }
.pe-columns[data-layout="sidebar-right"] .pe-column:last-child { flex: 1; }

/* Column placeholder for empty columns */
.pe-column-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60px;
    border: 2px dashed var(--gray-300, #d1d5db);
    border-radius: 6px;
    color: var(--text-light);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.pe-column-empty:hover {
    border-color: var(--primary);
    background: rgba(200, 16, 46, 0.03);
}

/* Add block button at bottom of column */
.pe-add-block-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 0.5rem;
    padding: 0.375rem;
    border: 1px dashed var(--gray-300);
    border-radius: 6px;
    background: transparent;
    color: var(--text-light);
    font-size: 0.75rem;
    cursor: pointer;
    width: 100%;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    opacity: 0;
}
.pe-section:hover .pe-add-block-btn,
.pe-section.selected .pe-add-block-btn {
    opacity: 1;
}
.pe-add-block-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(200, 16, 46, 0.03);
}

/* ==========================================================================
   Blocks
   ========================================================================== */
.pe-block {
    position: relative;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 4px;
    margin-bottom: 0.5rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    cursor: default;
}
.pe-block:hover {
    border-color: var(--gray-300, #d1d5db);
}
.pe-block.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(200, 16, 46, 0.10);
}

/* Block mini toolbar (top right) */
.pe-block-actions {
    position: absolute;
    top: -8px;
    right: -4px;
    display: flex;
    gap: 2px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    z-index: 5;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.1s;
}
.pe-block:hover .pe-block-actions,
.pe-block.selected .pe-block-actions {
    opacity: 1;
    pointer-events: auto;
}
.pe-block-action-btn {
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 3px;
    background: none;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}
.pe-block-action-btn:hover {
    background: var(--gray-100);
    color: var(--text-dark);
}
.pe-block-action-btn.danger:hover {
    background: var(--danger-bg, #fee2e2);
    color: var(--danger-color, #dc2626);
}

/* Block type-specific styling */
.pe-block-heading [contenteditable] {
    outline: none;
    min-height: 1.2em;
    cursor: text;
}
.pe-block-heading [contenteditable]:focus {
    outline: 2px solid rgba(200, 16, 46, 0.2);
    outline-offset: 2px;
    border-radius: 2px;
}
.pe-block-heading h1 { font-size: 2.25rem; font-weight: 700; line-height: 1.2; margin: 0; }
.pe-block-heading h2 { font-size: 1.75rem; font-weight: 700; line-height: 1.25; margin: 0; }
.pe-block-heading h3 { font-size: 1.375rem; font-weight: 600; line-height: 1.3; margin: 0; }
.pe-block-heading h4 { font-size: 1.125rem; font-weight: 600; line-height: 1.35; margin: 0; }

.pe-block-text [contenteditable] {
    outline: none;
    min-height: 1.5em;
    line-height: 1.6;
    cursor: text;
}
.pe-block-text [contenteditable]:focus {
    outline: 2px solid rgba(200, 16, 46, 0.2);
    outline-offset: 2px;
    border-radius: 2px;
}
.pe-block-text [contenteditable]:empty::before {
    content: attr(data-placeholder);
    color: var(--text-light);
}

/* Image block */
.pe-block-image img {
    width: 100%;
    display: block;
}
.pe-block-image .pe-image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem;
    background: var(--gray-50, #f9fafb);
    border: 2px dashed var(--gray-300);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color 0.15s;
    min-height: 120px;
}
.pe-block-image .pe-image-placeholder:hover {
    border-color: var(--primary);
}
.pe-block-image .pe-image-wrapper {
    position: relative;
    cursor: pointer;
}
.pe-block-image .pe-image-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.15s;
    border-radius: inherit;
}
.pe-block-image .pe-image-wrapper:hover .pe-image-overlay {
    opacity: 1;
}

/* Button block */
.pe-block-button .pe-button-preview {
    display: inline-block;
    padding: 12px 32px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 16px;
    text-decoration: none;
    pointer-events: none;
    user-select: none;
}

/* Video block */
.pe-block-video .pe-video-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem;
    background: #1a1a2e;
    border-radius: 8px;
    color: rgba(255,255,255,0.6);
    min-height: 100px;
}
.pe-block-video .pe-video-preview {
    position: relative;
    width: 100%;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}
.pe-block-video .pe-video-preview iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
    pointer-events: none;
}

/* Divider block */
.pe-block-divider hr {
    border: none;
    margin: 0;
}

/* Spacer block */
.pe-block-spacer {
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 5px,
        var(--gray-100, #f3f4f6) 5px,
        var(--gray-100, #f3f4f6) 10px
    );
    border-radius: 4px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pe-block-spacer-label {
    font-size: 0.6875rem;
    color: var(--text-light);
    background: var(--card-bg);
    padding: 0 0.5rem;
    border-radius: 3px;
}

/* HTML block */
.pe-block-html .pe-html-code {
    width: 100%;
    min-height: 80px;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.8125rem;
    line-height: 1.5;
    resize: vertical;
    background: var(--gray-50, #f9fafb);
    color: var(--text-dark);
}
.pe-block-html .pe-html-code:focus {
    outline: none;
    border-color: var(--primary);
}

/* ==========================================================================
   Section Template Insert Bars (Insert Header / Insert Footer)
   ========================================================================== */
.pe-section-template-bar {
    text-align: center;
    padding: 8px 0;
    width: 100%;
    max-width: 1200px;
}
.pe-insert-template-btn {
    border: 2px dashed var(--border-color, #ddd);
    background: none;
    color: var(--text-secondary, #6b7280);
    padding: 8px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}
.pe-insert-template-btn:hover {
    border-color: var(--primary-color, #C8102E);
    color: var(--primary-color, #C8102E);
}

/* Section Template Picker Grid */
.pe-section-template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}
.pe-section-template-card {
    border: 2px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.pe-section-template-card:hover {
    border-color: var(--primary-color, #C8102E);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.pe-section-template-preview {
    height: 40px;
    width: 100%;
}
.pe-section-template-info {
    padding: 10px 12px;
}
.pe-section-template-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 4px;
}
.pe-section-template-desc {
    font-size: 0.75rem;
    color: var(--text-muted, #6b7280);
    line-height: 1.4;
}

/* ==========================================================================
   Add Section button
   ========================================================================== */
.pe-add-section-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 1200px;
    padding: 1rem;
    margin-top: 0.5rem;
    border: 2px dashed var(--gray-300, #d1d5db);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.pe-add-section-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(200, 16, 46, 0.03);
}

/* ==========================================================================
   Properties Panel (right sidebar)
   ========================================================================== */
.pe-properties-panel {
    width: 280px;
    flex-shrink: 0;
    overflow-y: auto;
    border-left: 1px solid var(--border-color);
    background: var(--card-bg);
    padding: 1rem;
}
.pe-props-empty {
    text-align: center;
    color: var(--text-light);
    padding: 2rem 1rem;
    font-size: 0.8125rem;
}
.pe-props-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    padding-bottom: 0.375rem;
    border-bottom: 1px solid var(--border-color);
}
.pe-prop-group {
    margin-bottom: 1rem;
}
.pe-prop-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 0.25rem;
}
.pe-prop-input,
.pe-prop-select,
.pe-prop-textarea {
    width: 100%;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.8125rem;
    background: var(--card-bg);
    color: var(--text-dark);
}
.pe-prop-input:focus,
.pe-prop-select:focus,
.pe-prop-textarea:focus {
    outline: none;
    border-color: var(--primary);
}
.pe-prop-textarea {
    min-height: 60px;
    resize: vertical;
}
.pe-prop-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.pe-prop-row > * {
    flex: 1;
}
.pe-prop-color {
    width: 32px;
    height: 28px;
    padding: 1px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    flex: 0 0 32px;
}
.pe-prop-range {
    width: 100%;
    cursor: pointer;
}

/* ==========================================================================
   Page Settings Overlay
   ========================================================================== */
.pe-settings-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 999;
}
.pe-settings-overlay {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 360px;
    background: var(--card-bg);
    border-left: 1px solid var(--border-color);
    box-shadow: -4px 0 12px rgba(0,0,0,0.1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.pe-settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}
.pe-settings-body {
    padding: 1.25rem;
    flex: 1;
}
.pe-settings-body .form-group {
    margin-bottom: 1rem;
}
.pe-settings-body label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--text-dark);
}
.pe-settings-body input,
.pe-settings-body textarea,
.pe-settings-body select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--card-bg);
    color: var(--text-dark);
}
.pe-settings-body textarea {
    min-height: 80px;
    resize: vertical;
}

/* ==========================================================================
   SortableJS drag states
   ========================================================================== */
.pe-section.sortable-ghost {
    opacity: 0.4;
    border: 2px dashed var(--primary);
}
.pe-section.sortable-chosen {
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.pe-block.sortable-ghost {
    opacity: 0.4;
    border: 1px dashed var(--primary);
}
.pe-block.sortable-chosen {
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* ==========================================================================
   Media Library buttons in image placeholder
   ========================================================================== */
.pe-image-actions {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    justify-content: center;
}
.pe-img-action-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8125rem;
    transition: border-color 0.15s, color 0.15s;
}
.pe-img-action-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.pe-image-overlay-actions {
    display: flex;
    gap: 0.5rem;
}
.pe-image-overlay-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: 6px;
    background: rgba(255,255,255,0.15);
    color: white;
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: background 0.15s;
}
.pe-image-overlay-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* ==========================================================================
   Dark mode overrides
   ========================================================================== */
@media (prefers-color-scheme: dark) {
    .pe-block-palette {
        background: var(--card-bg, #1e293b);
    }
    .pe-palette-item:hover {
        background: var(--gray-800, #1e293b);
    }
    .pe-section {
        background: var(--card-bg, #1e293b);
    }
    .pe-section-toolbar {
        background: var(--gray-800, #1e293b);
    }
    .pe-block-spacer {
        background: repeating-linear-gradient(
            45deg,
            transparent,
            transparent 5px,
            var(--gray-700, #334155) 5px,
            var(--gray-700, #334155) 10px
        );
    }
    .pe-block-image .pe-image-placeholder {
        background: var(--gray-800);
    }
}
[data-theme="dark"] .pe-block-palette {
    background: var(--card-bg, #1e293b);
}
[data-theme="dark"] .pe-palette-item:hover {
    background: var(--gray-800, #1e293b);
}
[data-theme="dark"] .pe-section {
    background: var(--card-bg, #1e293b);
}
[data-theme="dark"] .pe-section-toolbar {
    background: var(--gray-800, #1e293b);
}
[data-theme="dark"] .pe-block-spacer {
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 5px,
        var(--gray-700, #334155) 5px,
        var(--gray-700, #334155) 10px
    );
}
[data-theme="dark"] .pe-block-image .pe-image-placeholder {
    background: var(--gray-800);
}

/* ==========================================================================
   Rich Text Floating Toolbar
   ========================================================================== */
.pe-rich-toolbar {
    position: fixed;
    z-index: 1000;
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 6px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 2px;
    pointer-events: auto;
    user-select: none;
}
.pe-rich-toolbar button {
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: none;
    cursor: pointer;
    color: var(--text-dark, #333);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    transition: background 0.12s, color 0.12s;
}
.pe-rich-toolbar button:hover {
    background: var(--gray-100, #f3f4f6);
}
.pe-rich-toolbar button.active {
    background: var(--primary, #C8102E);
    color: #fff;
}
.pe-rich-toolbar .pe-rt-sep {
    width: 1px;
    height: 18px;
    background: var(--border-color, #e2e8f0);
    margin: 0 2px;
}
.pe-rich-toolbar .pe-rt-color {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 2px solid var(--border-color, #e2e8f0);
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
}
.pe-rich-toolbar .pe-rt-color::-webkit-color-swatch-wrapper { padding: 0; }
.pe-rich-toolbar .pe-rt-color::-webkit-color-swatch { border: none; border-radius: 2px; }

/* Section name label in toolbar */
.pe-section-name {
    font-size: 0.75rem;
    font-weight: 600;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pe-section-name.unnamed {
    color: var(--text-muted);
    font-weight: 400;
    font-style: italic;
}
