/*
 * On-site inline editor (level 10 / admin only).
 * Toolbar is always visible for admins; outlines only appear while edit mode is active.
 */

#portal-site-editor-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999999;
    background: #1f2937;
    color: #f8fafc;
    padding: 8px 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

#pse-format-bar {
    flex-basis: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px solid rgba(248, 250, 252, 0.15);
}

#pse-format-bar button {
    background: #374151;
    color: #f8fafc;
    border: none;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

#pse-format-bar button:hover {
    background: #4b5563;
}

#pse-fmt-color-label {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

#pse-fmt-color {
    width: 28px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: none;
}

#pse-var-select {
    background: #374151;
    color: #f8fafc;
    border: none;
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 12px;
    max-width: 220px;
}

#portal-site-editor-toolbar button {
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

#portal-site-editor-toolbar button:hover {
    background: #1d4ed8;
}

#portal-site-editor-toolbar button:disabled {
    opacity: 0.6;
    cursor: default;
}

#pse-show-hidden.pse-active {
    background: #b45309;
}

#pse-show-hidden.pse-active:hover {
    background: #92400e;
}

#pse-status {
    color: #cbd5e1;
}

#pse-model-year-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.6);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#pse-model-year-modal {
    width: min(1100px, 100%);
    max-height: min(780px, 92vh);
    overflow: auto;
    background: #fff;
    color: #1f2937;
    border-radius: 8px;
    padding: 20px;
}

#pse-model-year-modal header, .pse-mpy-actions, .pse-mpy-row, .pse-mpy-editor > div:last-child {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

#pse-model-year-modal h2, #pse-model-year-modal h3 { margin: 0 0 12px; }
.pse-mpy-actions { justify-content: flex-start; margin-bottom: 16px; }
.pse-mpy-search-label { display: block; margin-bottom: 12px; color: #334155; font-size: 12px; font-weight: 600; }
.pse-mpy-search { display: block; width: 100%; box-sizing: border-box; margin-top: 4px; padding: 9px 10px; border: 1px solid #94a3b8; border-radius: 5px; font: inherit; font-weight: 400; }
.pse-mpy-status { color: #475569; font-size: 13px; }
.pse-mpy-error { color: #b91c1c; }
.pse-mpy-tree { border: 1px solid #d1d5db; max-height: 560px; overflow: auto; background: #f8fafc; }
.pse-mpy-brand { border-bottom: 1px solid #cbd5e1; }
.pse-mpy-brand > summary { padding: 10px 12px; background: #e2e8f0; cursor: pointer; font-weight: 700; }
.pse-mpy-brand > summary span { color: #64748b; font-size: 12px; font-weight: 500; }
.pse-mpy-folder { margin-left: 16px; border-left: 2px solid #93c5fd; }
.pse-mpy-folder > summary { padding: 10px 12px; cursor: pointer; background: #fff; }
.pse-mpy-folder-name { font-weight: 700; }
.pse-mpy-folder-meta { margin-left: 8px; color: #64748b; font-size: 12px; }
.pse-mpy-folder-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; background: #f1f5f9; }
.pse-mpy-folder-actions button { padding: 5px 8px; border: 0; border-radius: 4px; background: #2563eb; color: #fff; cursor: pointer; font-size: 12px; }
.pse-mpy-folder-actions .pse-mpy-delete-model { background: #b91c1c; }
.pse-mpy-children { margin-left: 16px; border-left: 1px solid #cbd5e1; }
.pse-mpy-empty-child { padding: 10px 12px; color: #64748b; font-size: 12px; font-style: italic; }
.pse-mpy-row { padding: 9px 10px; border-bottom: 1px solid #e5e7eb; font-size: 13px; }
.pse-mpy-row span { overflow-wrap: anywhere; }
.pse-mpy-row button, .pse-mpy-actions button, .pse-mpy-editor button, .pse-mpy-close { padding: 6px 10px; border: 0; border-radius: 4px; background: #2563eb; color: #fff; cursor: pointer; }
.pse-mpy-row button + button { margin-left: 5px; background: #b91c1c; }
.pse-mpy-close { background: #475569; }
.pse-mpy-addon-rules { margin-bottom: 16px; padding: 12px; border: 1px solid #cbd5e1; border-radius: 6px; background: #f8fafc; }
.pse-mpy-addon-rules > summary { cursor: pointer; font-weight: 700; }
.pse-mpy-addon-rules p { font-size: 13px; line-height: 1.5; }
.pse-mpy-addon-form fieldset { min-width: 0; margin: 12px 0; padding: 12px; border: 1px solid #cbd5e1; }
.pse-mpy-addon-form h3 { margin-top: 16px !important; }
.pse-mpy-addon-table-wrap { overflow-x: auto; margin: 8px 0; }
.pse-mpy-addon-form table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
.pse-mpy-addon-form caption { text-align: left; color: #475569; padding-bottom: 6px; }
.pse-mpy-addon-form th, .pse-mpy-addon-form td { padding: 8px; border-bottom: 1px solid #cbd5e1; }
.pse-mpy-addon-form th { background: #e2e8f0; }
.pse-mpy-addon-form input { width: 100%; min-width: 95px; box-sizing: border-box; padding: 8px; border: 1px solid #94a3b8; border-radius: 4px; font: inherit; }
.pse-mpy-addon-form button { padding: 7px 10px; border: 0; border-radius: 4px; background: #2563eb; color: #fff; cursor: pointer; }
.pse-mpy-addon-form .pse-mpy-addon-remove { background: #b91c1c; }
.pse-mpy-addon-form fieldset:disabled button { opacity: 0.55; cursor: wait; }
.pse-mpy-addon-save-row { margin-top: 18px; }
.pse-mpy-addon-status { display: block; margin: 8px 0; font-size: 13px; }
.pse-mpy-editor-overlay { position: fixed; inset: 0; z-index: 1000002; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(15, 23, 42, 0.45); }
.pse-mpy-editor { width: min(700px, 100%); max-height: 90vh; overflow: auto; padding: 20px; background: #fff; color: #1f2937; border-radius: 8px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pse-mpy-editor h3, .pse-mpy-editor > div:last-child { grid-column: 1 / -1; }
.pse-mpy-editor label { font-size: 12px; font-weight: 600; }
.pse-mpy-editor input, .pse-mpy-editor select { display: block; width: 100%; box-sizing: border-box; margin-top: 4px; padding: 8px; border: 1px solid #94a3b8; border-radius: 4px; background: #fff; }
@media (max-width: 700px) { .pse-mpy-editor { grid-template-columns: 1fr; } .pse-mpy-folder-meta { display: block; margin: 3px 0 0; } }

#pse-price-overlay { position: fixed; inset: 0; z-index: 1000004; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(15, 23, 42, 0.6); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
#pse-price-modal { width: min(1400px, 100%); max-height: 92vh; overflow: auto; box-sizing: border-box; background: #fff; color: #1f2937; border-radius: 8px; padding: 20px; }
#pse-price-modal header, .pse-price-actions, .pse-price-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#pse-price-modal header { justify-content: space-between; }
#pse-price-modal h2 { margin: 0; }
.pse-price-actions, .pse-price-bulk { margin: 10px 0; }
.pse-price-help { color: #475569; font-size: 13px; line-height: 1.5; }
#pse-price-modal button, .pse-price-file, .pse-seo-open-price-manager { padding: 6px 10px; border: 0; border-radius: 4px; background: #2563eb; color: #fff; cursor: pointer; font: inherit; font-size: 13px; }
#pse-price-modal .pse-price-close { background: #475569; }
#pse-price-modal .pse-price-delete { background: #b91c1c; }
#pse-price-modal td button + button { margin-left: 4px; }
.pse-price-search, .pse-price-bulk input, .pse-price-bulk select { padding: 6px 8px; border: 1px solid #94a3b8; border-radius: 4px; font: inherit; }
.pse-price-status { font-size: 13px; color: #475569; }
.pse-price-table-wrap { overflow-x: auto; border: 1px solid #cbd5e1; }
.pse-price-table-wrap table { width: 100%; border-collapse: collapse; font-size: 13px; text-align: left; }
.pse-price-table-wrap th, .pse-price-table-wrap td { padding: 6px 8px; border-bottom: 1px solid #e2e8f0; white-space: nowrap; }
.pse-price-table-wrap th { position: sticky; top: 0; background: #e2e8f0; }
.pse-price-table-wrap td input[type="number"] { width: 100px; padding: 4px 6px; border: 1px solid #94a3b8; border-radius: 4px; }
.pse-price-any { color: #94a3b8; font-style: italic; }
.pse-price-missing td:last-child { color: #b91c1c; }
.pse-price-editor-overlay { z-index: 1000005; }
.pse-seo-price-rules { margin: 12px 0; }

.pse-seo-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000003;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
    background: rgba(15, 23, 42, 0.68);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.pse-seo-modal {
    width: min(900px, 100%);
    max-height: min(900px, 94vh);
    overflow: auto;
    box-sizing: border-box;
    padding: 22px;
    border-radius: 10px;
    background: #fff;
    color: #1f2937;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.38);
}

.pse-seo-modal header,
.pse-seo-modal footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.pse-seo-modal h2 { margin: 0; font-size: 22px; }
.pse-seo-modal header p { margin: 4px 0 0; color: #64748b; overflow-wrap: anywhere; }
.pse-seo-modal button { border: 0; border-radius: 5px; padding: 8px 13px; cursor: pointer; }
.pse-seo-modal button:disabled { opacity: 0.6; cursor: wait; }
.pse-seo-modal .pse-seo-close { padding: 2px 9px; background: #e2e8f0; color: #1f2937; font-size: 23px; }
.pse-seo-modal .pse-seo-save { background: #2563eb; color: #fff; font-weight: 700; }

.pse-seo-score {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 0 12px;
    color: #334155;
    font-weight: 700;
}

.pse-seo-score-value {
    display: inline-flex;
    width: 48px;
    height: 48px;
    align-items: center;
    justify-content: center;
    border: 4px solid #2563eb;
    border-radius: 50%;
    color: #1d4ed8;
    font-size: 17px;
}

.pse-seo-tabs { display: flex; gap: 5px; margin: 0 0 14px; border-bottom: 1px solid #cbd5e1; }
.pse-seo-modal .pse-seo-tabs [role="tab"] { border-radius: 5px 5px 0 0; background: transparent; color: #475569; }
.pse-seo-modal .pse-seo-tabs [role="tab"][aria-selected="true"] { background: #2563eb; color: #fff; }
.pse-seo-checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-bottom: 18px; }
.pse-seo-checks > div { display: grid; gap: 3px; padding: 8px 10px; border-radius: 5px; background: #f8fafc; font-size: 12px; }
.pse-seo-checks span { color: #64748b; }
.pse-seo-check-pass strong { color: #15803d; }
.pse-seo-check-warn strong { color: #b45309; }
.pse-seo-checks .pse-seo-issue { color: #b91c1c; overflow-wrap: anywhere; }
.pse-seo-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.pse-seo-tab-panel { display: grid; grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 12px; }
.pse-seo-tab-panel[hidden],
.pse-seo-tab-panel [hidden] { display: none !important; }
.pse-seo-tab-panel > label,
.pse-seo-tab-panel > details { display: block; min-width: 0; color: #334155; font-size: 12px; font-weight: 700; }
.pse-seo-tab-panel > .pse-seo-schema-data { grid-column: 1 / -1; }
.pse-seo-fields input:not([type="checkbox"]),
.pse-seo-fields textarea,
.pse-seo-fields select {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin-top: 5px;
    padding: 9px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    background: #fff;
    color: #1f2937;
    font: inherit;
    font-weight: 400;
}

.pse-seo-fields fieldset { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 15px; border: 1px solid #cbd5e1; border-radius: 5px; }
.pse-seo-fields legend { padding: 0 5px; color: #334155; font-size: 12px; font-weight: 700; }
.pse-seo-fields .pse-seo-check { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.pse-seo-image-field input { margin-bottom: 6px; }
.pse-seo-modal .pse-seo-gallery-pick { background: #475569; color: #fff; font-size: 11px; }
.pse-seo-schema-data textarea { min-height: 150px; resize: vertical; font-family: Consolas, "Courier New", monospace; }
.pse-seo-schema-data span { display: block; margin-top: 5px; color: #64748b; font-size: 11px; font-weight: 400; }
.pse-seo-schema-data summary { cursor: pointer; }
.pse-seo-variant-editor { grid-column: 1 / -1; display: grid; gap: 10px; }
.pse-seo-variant-editor h3 { margin: 0; color: #1f2937; font-size: 15px; }
.pse-seo-variant-editor > p,
.pse-seo-variant-help { margin: 0; color: #64748b; font-size: 11px; font-weight: 400; }
.pse-seo-variant-import { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
.pse-seo-variant-import label { display: grid; gap: 4px; min-width: 220px; color: #334155; font-size: 11px; font-weight: 600; }
.pse-seo-variant-import select { padding: 7px 8px; border: 1px solid #cbd5e1; border-radius: 4px; background: #fff; font: inherit; font-weight: 400; }
.pse-seo-modal .pse-seo-import-variants { background: #475569; color: #fff; }
.pse-seo-import-status { flex: 1 1 100%; color: #475569; font-size: 11px; }
.pse-seo-variant { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 12px; border: 1px solid #cbd5e1; border-radius: 6px; background: #f8fafc; }
.pse-seo-variant-heading { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
.pse-seo-variant-heading button { background: #fee2e2; color: #991b1b; }
.pse-seo-variant label { display: block; min-width: 0; color: #334155; font-size: 11px; font-weight: 600; }
.pse-seo-variant input,
.pse-seo-variant select { display: block; width: 100%; box-sizing: border-box; margin-top: 4px; padding: 7px 8px; border: 1px solid #cbd5e1; border-radius: 4px; background: #fff; font: inherit; font-weight: 400; }
.pse-seo-variant .pse-seo-variant-image { grid-column: 1 / -1; }
.pse-seo-variant-image button { margin-top: 6px; }
.pse-seo-modal .pse-seo-add-variant { justify-self: start; background: #475569; color: #fff; }
.pse-site-url-settings { display: grid; gap: 6px; margin-top: 16px; color: #334155; font-size: 12px; font-weight: 700; }
.pse-seo-tab-panel .pse-site-url-settings { grid-column: 1 / -1; }
.pse-site-url-settings > div { display: flex; gap: 8px; }
.pse-site-url-settings input { flex: 1; min-width: 0; padding: 9px 10px; border: 1px solid #cbd5e1; border-radius: 5px; font: inherit; font-weight: 400; }
.pse-seo-modal .pse-site-url-save { background: #475569; color: #fff; font-weight: 700; }
.pse-site-url-status { min-height: 1em; color: #475569; font-weight: 400; }
.pse-seo-modal footer { margin-top: 16px; }
.pse-seo-status { flex: 1; color: #475569; font-size: 12px; }

@media (max-width: 650px) {
    .pse-seo-overlay { padding: 10px; }
    .pse-seo-modal { padding: 16px; }
    .pse-seo-checks, .pse-seo-fields, .pse-seo-tab-panel { grid-template-columns: 1fr; }
    .pse-seo-fields fieldset { grid-column: auto; }
    .pse-seo-tab-panel > .pse-seo-schema-data, .pse-seo-tab-panel .pse-site-url-settings { grid-column: auto; }
    .pse-seo-tabs { overflow-x: auto; }
    .pse-seo-variant { grid-template-columns: 1fr; }
    .pse-seo-variant-heading, .pse-seo-variant .pse-seo-variant-image { grid-column: auto; }
    .pse-seo-modal footer { align-items: flex-start; flex-direction: column; }
}

#pse-blog-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.6);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#pse-blog-modal {
    width: min(900px, 100%);
    max-height: min(860px, 94vh);
    overflow: auto;
    background: #fff;
    color: #1f2937;
    border-radius: 8px;
    padding: 20px;
}

#pse-blog-modal header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#pse-blog-modal h2 { margin: 0 0 12px; }
.pse-blog-close { padding: 6px 10px; border: 0; border-radius: 4px; background: #475569; color: #fff; cursor: pointer; }
.pse-blog-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.pse-blog-form .pse-blog-wide { grid-column: 1 / -1; }
.pse-blog-form label, .pse-blog-label { display: block; font-size: 12px; font-weight: 600; color: #334155; }
.pse-blog-form input[type="text"], .pse-blog-form input:not([type]), .pse-blog-form input[type="datetime-local"], .pse-blog-form textarea {
    display: block; width: 100%; box-sizing: border-box; margin-top: 4px; padding: 8px;
    border: 1px solid #94a3b8; border-radius: 4px; font: inherit; font-weight: 400; background: #fff;
}
.pse-blog-check { display: flex; align-items: center; gap: 6px; align-self: end; }
.pse-blog-check input { width: auto; }
.pse-blog-tags { border: 1px solid #d1d5db; border-radius: 6px; padding: 10px 12px; }
.pse-blog-tags legend { font-size: 12px; font-weight: 700; color: #334155; padding: 0 4px; }
.pse-blog-tag-list { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 10px; }
.pse-blog-tag-list label { display: flex; align-items: center; gap: 5px; font-weight: 400; }
.pse-blog-tag-list em { color: #b45309; font-style: italic; }
.pse-blog-format { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 0; align-items: center; }
.pse-blog-format button { padding: 5px 9px; border: 1px solid #cbd5e1; border-radius: 4px; background: #f1f5f9; color: #1f2937; cursor: pointer; }
.pse-blog-format select { padding: 4px 6px; border: 1px solid #cbd5e1; border-radius: 4px; background: #f1f5f9; color: #1f2937; }
.pse-rt-color-label { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 400; padding: 2px 4px; border: 1px solid #cbd5e1; border-radius: 4px; background: #f1f5f9; }
.pse-rt-color-label input[type="color"] { width: 22px; height: 22px; padding: 0; border: 0; background: none; cursor: pointer; }
.pse-rt-hover-swatch { color: #1a5fb4; }
.pse-blog-body {
    min-height: 240px; max-height: 420px; overflow: auto; margin-top: 6px; padding: 12px;
    border: 1px solid #94a3b8; border-radius: 0 0 4px 4px; background: #fff; line-height: 1.55;
}
.pse-inline-blog-toolbar {
    position: sticky;
    top: 48px;
    z-index: 1000000;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
    margin: 8px auto 0;
    padding: 8px;
    max-width: min(900px, calc(100vw - 24px));
    border: 1px solid #334155;
    border-radius: 8px;
    background: #1f2937;
    color: #f8fafc;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.pse-inline-blog-toolbar button {
    min-height: 28px;
    padding: 5px 9px;
    border: 1px solid #475569;
    border-radius: 5px;
    background: #334155;
    color: #f8fafc;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.pse-inline-blog-toolbar button:hover { background: #475569; }
.pse-inline-blog-toolbar .pse-inline-blog-save { background: #2563eb; border-color: #1d4ed8; }
.pse-inline-blog-spacer { flex: 1 1 auto; min-width: 8px; }
.pse-inline-blog-status { font-size: 12px; color: #cbd5e1; }
.pse-inline-blog-body-active {
    outline: 2px dashed #2563eb;
    outline-offset: 6px;
    background: rgba(239, 246, 255, 0.35);
    min-height: 120px;
}
.pse-embed-resizer {
    position: relative;
    display: block;
    min-width: 120px;
    min-height: 90px;
    max-width: 100%;
    resize: none;
    overflow: hidden;
    margin: 8px 0;
    border: 1px dashed #2563eb;
    box-sizing: border-box;
}
.pse-embed-resizer.pse-embed-resizing {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}
.pse-embed-resize-handle {
    position: absolute;
    z-index: 3;
    right: -2px;
    bottom: -2px;
    width: 22px;
    height: 22px;
    border-radius: 6px 0 6px 0;
    background: #2563eb;
    cursor: nwse-resize;
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.22);
    touch-action: none;
}
.pse-embed-resize-handle::before {
    content: "";
    position: absolute;
    right: 5px;
    bottom: 5px;
    width: 9px;
    height: 9px;
    background: linear-gradient(135deg, transparent 45%, #ffffff 46% 58%, transparent 59% 68%, #ffffff 69% 81%, transparent 82%);
}
.pse-image-resizer {
    position: relative;
    display: block;
    min-width: 48px;
    min-height: 0;
    max-width: 100%;
    resize: none;
    overflow: hidden;
    margin: 8px 0;
    border: 1px dashed #16a34a;
    background: repeating-conic-gradient(#f1f5f9 0% 25%, #fff 0% 50%) 50% / 12px 12px;
    box-sizing: border-box;
}
.pse-image-resizer.pse-image-resizing {
    outline: 2px solid #16a34a;
    outline-offset: 2px;
}
.pse-image-resize-handle {
    position: absolute;
    z-index: 3;
    right: -2px;
    bottom: -2px;
    width: 22px;
    height: 22px;
    border-radius: 6px 0 6px 0;
    background: #16a34a;
    cursor: nwse-resize;
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.22);
    touch-action: none;
}
.pse-image-resize-handle::before {
    content: "";
    position: absolute;
    right: 5px;
    bottom: 5px;
    width: 9px;
    height: 9px;
    background: linear-gradient(135deg, transparent 45%, #ffffff 46% 58%, transparent 59% 68%, #ffffff 69% 81%, transparent 82%);
}
.pse-embed-resizer.pse-embed-inline {
    display: inline-block;
    vertical-align: top;
    margin-right: 8px;
}
.pse-image-resizer.pse-image-inline {
    display: inline-block;
    vertical-align: top;
    margin-right: 8px;
}
.pse-embed-resizer.pse-embed-dragging { opacity: 0.45; }
.pse-image-resizer.pse-blog-media-dragging { opacity: 0.45; }
.pse-embed-controls {
    position: absolute;
    z-index: 2;
    top: 4px;
    left: 4px;
    display: flex;
    gap: 3px;
    align-items: center;
    padding: 3px;
    background: rgba(15, 23, 42, 0.88);
    border-radius: 4px;
}
.pse-embed-controls button,
.pse-embed-drag {
    min-height: 24px;
    padding: 3px 7px;
    border: 0;
    border-radius: 3px;
    background: #f8fafc;
    color: #0f172a;
    font: 600 11px/1 sans-serif;
}
.pse-embed-controls button { cursor: pointer; }
.pse-embed-drag { cursor: move; }
.pse-embed-resizer iframe {
    display: block;
    width: 100% !important;
    height: 100% !important;
    border: 0;
    pointer-events: none;
}
.pse-image-resizer img {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: fill;
    pointer-events: none;
}
.pse-embed-resizer::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    width: 14px;
    height: 14px;
    background: linear-gradient(135deg, transparent 45%, #2563eb 46% 58%, transparent 59% 68%, #2563eb 69% 81%, transparent 82%);
    pointer-events: none;
}
.pse-image-resizer::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    width: 14px;
    height: 14px;
    background: linear-gradient(135deg, transparent 45%, #16a34a 46% 58%, transparent 59% 68%, #16a34a 69% 81%, transparent 82%);
    pointer-events: none;
}

body:not(.pse-edit-mode) .pse-embed-controls,
body:not(.pse-edit-mode) .pse-image-resize-handle,
body:not(.pse-edit-mode) .pse-image-resizer::after,
body:not(.pse-edit-mode) .pse-embed-resizer::after {
    display: none !important;
    pointer-events: none !important;
}
.pse-rt-bubble {
    position: fixed; z-index: 1000003; display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
    max-width: 520px; padding: 6px; background: #1f2937; border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.pse-rt-bubble[hidden] { display: none; }
.pse-rt-bubble button, .pse-rt-bubble select { font-size: 12px; padding: 4px 6px; border: 1px solid #475569; border-radius: 4px; background: #334155; color: #f1f5f9; cursor: pointer; }
.pse-rt-bubble .pse-rt-color-label { background: #334155; border-color: #475569; color: #f1f5f9; }

.pse-blog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.pse-blog-actions button { padding: 8px 14px; border: 0; border-radius: 4px; background: #2563eb; color: #fff; cursor: pointer; }
.pse-blog-actions .pse-blog-cancel { background: #475569; }
.pse-blog-actions .pse-blog-delete { background: #b91c1c; }
.pse-blog-status { flex: 1; color: #475569; font-size: 13px; }
.pse-blog-error { color: #b91c1c; }
@media (max-width: 700px) { .pse-blog-form { grid-template-columns: 1fr; } }

/* top/body padding are positioned by site-editor.js (accounts for #global-status-bar height) */

/* Faded outline around editable widgets, only shown while edit mode is active */
body.pse-edit-mode [data-editable="true"] {
    outline: 2px dashed rgba(37, 99, 235, 0.45);
    outline-offset: 2px;

[data-editable="true"] {
    white-space: pre-wrap;
}
    cursor: text;
    transition: outline-color 0.15s ease;
}

body.pse-edit-mode [data-editable="true"]:hover {
    outline-color: rgba(37, 99, 235, 0.9);
}

/* Widgets whose text contains {dynamic} placeholders get an orange outline */
body.pse-edit-mode [data-editable="true"][data-edit-dynamic="true"] {
    outline-color: rgba(249, 115, 22, 0.6);
}

body.pse-edit-mode [data-editable="true"][data-edit-dynamic="true"]:hover {
    outline-color: rgba(249, 115, 22, 0.95);
}

body.pse-edit-mode [data-editable="true"].pse-dirty {
    outline-style: solid;
}

/* Confirm-changes diff modal shown before saving */
#pse-confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000000;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

#pse-confirm-modal {
    background: #fff;
    color: #1f2937;
    border-radius: 8px;
    max-width: 640px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#pse-confirm-modal h3 {
    margin: 0;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 16px;
}

.pse-confirm-source {
    color: #64748b;
    font-family: Consolas, monospace;
    font-size: 11px;
    padding: 8px 20px;
    overflow-wrap: anywhere;
}

#pse-confirm-list {
    overflow-y: auto;
    padding: 12px 20px;
}

.pse-confirm-row {
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
}

.pse-confirm-row:last-child {
    border-bottom: none;
}

.pse-confirm-path {
    font-weight: 600;
    color: #475569;
    margin-bottom: 4px;
    font-family: Consolas, monospace;
}

.pse-confirm-old,
.pse-confirm-new {
    white-space: pre-wrap;
    word-break: break-word;
    padding: 2px 6px;
    border-radius: 4px;
}

.pse-confirm-old {
    background: rgba(239, 68, 68, 0.1);
    color: #b91c1c;
    text-decoration: line-through;
}

.pse-confirm-new {
    background: rgba(34, 197, 94, 0.12);
    color: #15803d;
    margin-top: 4px;
}

.pse-confirm-context-label {
    color: #64748b;
    font-size: 11px;
    font-weight: 600;
    margin-top: 10px;
    margin-bottom: 4px;
}

.pse-confirm-context {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 4px;
    margin: 0;
    max-height: 180px;
    overflow: auto;
    padding: 8px;
    font-family: Consolas, monospace;
    font-size: 11px;
    line-height: 1.4;
    white-space: pre;
}

.pse-confirm-context-removed {
    background: rgba(239, 68, 68, 0.18);
    color: #fecaca;
}

.pse-confirm-context-added {
    background: rgba(34, 197, 94, 0.2);
    color: #bbf7d0;
}

#pse-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid #e5e7eb;
}

#pse-confirm-actions button {
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

#pse-confirm-cancel {
    background: #e5e7eb;
    color: #1f2937;
}

#pse-confirm-cancel:hover {
    background: #d1d5db;
}

#pse-confirm-ok {
    background: #2563eb;
    color: #fff;
}

#pse-confirm-ok:hover {
    background: #1d4ed8;
}

/* Advanced SQL-driven variable builder popup */
#pse-adv-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000000;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

#pse-adv-modal {
    background: #fff;
    color: #1f2937;
    border-radius: 8px;
    max-width: 520px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#pse-adv-modal h3 {
    margin: 0 0 8px;
    font-size: 16px;
}

.pse-adv-help {
    color: #64748b;
    font-size: 12px;
    margin-bottom: 16px;
    line-height: 1.4;
}

.pse-adv-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 14px;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
}

.pse-adv-field select,
.pse-adv-field input[type="text"] {
    font-weight: normal;
    font-size: 13px;
    padding: 6px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #1f2937;
}

.pse-adv-compare-wrap {
    display: flex;
    gap: 6px;
}

.pse-adv-compare-wrap input[type="text"] {
    flex: 1;
}

.pse-adv-compare-wrap select {
    max-width: 130px;
}

.pse-adv-filters-label {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.pse-adv-filter-row {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
}

.pse-adv-filter-row select,
.pse-adv-filter-row input[type="text"] {
    font-size: 13px;
    padding: 6px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #1f2937;
    min-width: 0;
}

.pse-adv-filter-row > select:first-child {
    flex: 0 0 130px;
}

.pse-adv-filter-row input[type="text"] {
    flex: 1;
}

.pse-adv-filter-row > select:nth-child(3) {
    flex: 0 0 120px;
}

.pse-adv-remove-filter {
    flex: 0 0 auto;
    border: none;
    background: #e5e7eb;
    color: #4b5563;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.pse-adv-remove-filter:hover {
    background: #fecaca;
    color: #b91c1c;
}

.pse-adv-add-filter {
    border: 1px dashed #9ca3af;
    background: transparent;
    color: #374151;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
    margin-bottom: 14px;
}

.pse-adv-add-filter:hover {
    background: #f3f4f6;
}

/* Live value chips shown in place of raw {..} tokens while editing */
.pse-token {
    display: inline;
    outline: 2px solid #f59e0b;
    outline-offset: 1px;
    border-radius: 3px;
    background: rgba(245, 158, 11, 0.12);
    cursor: pointer;
    transition: outline-color 0.12s ease, background 0.12s ease;
}

.pse-token:hover {
    outline-color: #2563eb;
    background: rgba(37, 99, 235, 0.14);
}

.pse-token-selected {
    outline-color: #2563eb;
    background: rgba(37, 99, 235, 0.24);
}

.pse-token-readonly {
    outline-style: dashed;
    cursor: default;
}

.pse-token-error {
    outline-color: #dc2626;
    background: rgba(220, 38, 38, 0.14);
}

#pse-token-mode,
#pse-var-remove {
    background: #374151;
    color: #f8fafc;
    border: none;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
}

#pse-var-remove:disabled {
    opacity: 0.45;
    cursor: default;
}

/* Value editor popup for a selected token chip */
#pse-value-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000001;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

#pse-value-modal {
    background: #fff;
    color: #1f2937;
    border-radius: 8px;
    width: 100%;
    max-width: 860px;
    max-height: calc(100vh - 48px);
    overflow: auto;
    padding: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#pse-value-modal h3 {
    margin: 0 0 6px;
    font-size: 16px;
}

.pse-value-note {
    color: #64748b;
    font-size: 12px;
    line-height: 1.4;
    margin-bottom: 10px;
}

.pse-value-source {
    background: #0f172a;
    color: #bbf7d0;
    border-radius: 6px;
    padding: 8px;
    margin: 0 0 10px;
    font-family: Consolas, monospace;
    font-size: 11px;
    white-space: pre-wrap;
    word-break: break-word;
}

.pse-value-preview-table {
    width: 100%;
    max-width: 100%;
    display: block;
    overflow: auto;
    border-collapse: collapse;
    border: 1px solid #d1d5db;
    margin: -4px 0 12px;
    font-size: 12px;
    white-space: nowrap;
}

.pse-value-preview-table th,
.pse-value-preview-table td {
    border: 1px solid #e5e7eb;
    padding: 6px 8px;
    text-align: left;
    vertical-align: top;
}

.pse-value-preview-table th {
    background: #f1f5f9;
    color: #334155;
    font-weight: 700;
}

.pse-img-section-heading {
    margin: 16px 0 8px;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
    color: #334155;
    font-size: 13px;
}

#pse-value-input {
    width: 100%;
    min-height: 70px;
    box-sizing: border-box;
    padding: 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

#pse-value-error {
    color: #b91c1c;
    font-size: 12px;
    min-height: 16px;
    margin: 6px 0;
}

#pse-value-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

#pse-value-actions button {
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

#pse-value-actions button:first-child {
    background: #e5e7eb;
    color: #1f2937;
}

#pse-value-actions button:last-child {
    background: #2563eb;
    color: #fff;
}

#pse-value-actions button:last-child:disabled {
    opacity: 0.6;
    cursor: default;
}

.pse-adv-checkbox-field {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #374151;
    margin-bottom: 14px;
}

.pse-adv-preview-label {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
}

#pse-adv-preview {
    background: #0f172a;
    color: #bbf7d0;
    border-radius: 6px;
    padding: 10px;
    font-family: Consolas, monospace;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 20px;
    margin: 0 0 8px;
}

#pse-adv-error {
    color: #b91c1c;
    font-size: 12px;
    min-height: 16px;
    margin-bottom: 8px;
}

#pse-adv-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

#pse-adv-actions button {
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

#pse-adv-actions button:first-child {
    background: #e5e7eb;
    color: #1f2937;
}

#pse-adv-actions button:first-child:hover {
    background: #d1d5db;
}

#pse-adv-actions button:last-child {
    background: #2563eb;
    color: #fff;
}

#pse-adv-actions button:last-child:hover {
    background: #1d4ed8;
}

/* Condition Block cog: zero-size marker, out-of-flow so it cannot affect the
   surrounding grid/flex layout; the visible cog is a fixed-position button
   the client floats above the marker's on-screen position (edit mode only). */
.pse-condition-marker {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    pointer-events: none;
}

.pse-condition-cog {
    display: none;
    position: fixed;
    align-items: center;
    justify-content: center;
    z-index: 999998;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid #f59e0b;
    border-radius: 50%;
    background: #fff7ed;
    color: #b45309;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    transform: translate(-4px, -4px);
}

body.pse-edit-mode .pse-condition-cog {
    display: flex;
}

.pse-condition-cog:hover {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

/* Forced-visible via the "Show Hidden Conditions" toggle: its own filter currently fails */
.pse-condition-cog-hidden {
    border-color: #dc2626;
    background: #fef2f2;
    color: #b91c1c;
}

.pse-condition-cog-hidden:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

/* Image manager: hover cog on Image/Background/image-Button widgets */

/* Background widgets normally use pointer-events:none (page-sizing.css) so clicks
   pass through to content stacked on top of them; re-enable hover/click in edit
   mode so the image manager cog can actually be reached. */
body.pse-edit-mode [data-editable-image="true"] {
    pointer-events: auto !important;
}

.pse-image-cog {
    display: none;
    position: fixed;
    align-items: center;
    justify-content: center;
    z-index: 999997;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid #16a34a;
    border-radius: 50%;
    background: #f0fdf4;
    color: #15803d;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.pse-image-cog:hover {
    background: #16a34a;
    border-color: #16a34a;
    color: #fff;
}

/* JS toggles this class on hover; setting inline style.display='' would only fall
   back to the "display: none" rule above, so a dedicated visible class is required. */
.pse-image-cog-visible {
    display: flex;
}

/* Not yet wired to a widget property; still shown per-image, just muted */
.pse-image-cog-unmanaged {
    border-style: dashed;
    background: #f8fafc;
    color: #64748b;
    border-color: #94a3b8;
}

.pse-image-cog-unmanaged:hover {
    background: #64748b;
    border-color: #64748b;
    color: #fff;
}

#pse-img-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000001;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

#pse-img-modal {
    background: #fff;
    color: #1f2937;
    border-radius: 8px;
    width: 100%;
    max-width: 440px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#pse-img-modal.pse-gallery-alt-modal {
    max-width: 900px;
}

#pse-img-modal h3 {
    margin: 0 0 8px;
    font-size: 16px;
}

.pse-img-help {
    color: #64748b;
    font-size: 12px;
    line-height: 1.4;
    margin-bottom: 12px;
}

.pse-gallery-alt-list {
    display: grid;
    gap: 10px;
    max-height: 55vh;
    overflow: auto;
    margin: 12px 0;
}

.pse-gallery-alt-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #f8fafc;
}

.pse-gallery-alt-row label {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 4px;
    color: #374151;
    font-size: 12px;
    font-weight: 600;
}

.pse-gallery-alt-row label span {
    text-transform: uppercase;
}

.pse-gallery-alt-row input {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 7px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    background: #fff;
    color: #1f2937;
    font-size: 12px;
    font-weight: 400;
}

.pse-gallery-alt-row input[readonly] {
    background: #f1f5f9;
}

.pse-img-preview {
    display: block;
    max-width: 100%;
    max-height: 160px;
    margin: 0 auto 14px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    object-fit: contain;
    background: repeating-conic-gradient(#f3f4f6 0% 25%, #fff 0% 50%) 50% / 16px 16px;
}

.pse-img-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
}

.pse-img-field input[type="text"],
.pse-img-field input[type="url"],
.pse-img-field input[type="file"] {
    font-weight: normal;
    font-size: 13px;
    padding: 6px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #1f2937;
}

#pse-img-error {
    color: #b91c1c;
    font-size: 12px;
    min-height: 16px;
    margin: 6px 0;
}

#pse-img-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

#pse-img-actions button {
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

#pse-img-actions .pse-img-remove {
    background: #fef2f2;
    color: #b91c1c;
    margin-right: auto;
}

#pse-img-actions .pse-img-remove:hover {
    background: #fee2e2;
}

#pse-img-actions button:not(.pse-img-remove):first-of-type {
    background: #e5e7eb;
    color: #1f2937;
}

#pse-img-actions button:last-child {
    background: #2563eb;
    color: #fff;
}

#pse-img-actions button:disabled {
    opacity: 0.6;
    cursor: default;
}

@media (max-width: 600px) {
    .pse-gallery-alt-row {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Condition Block settings modal */
#pse-cond-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000001;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

#pse-cond-modal {
    background: #fff;
    color: #1f2937;
    border-radius: 8px;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#pse-cond-modal h3 {
    margin: 0 0 8px;
    font-size: 16px;
}

.pse-cond-help {
    color: #64748b;
    font-size: 12px;
    line-height: 1.4;
    margin-bottom: 16px;
}

.pse-cond-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
}

.pse-cond-field select,
.pse-cond-field input {
    font-weight: normal;
    font-size: 13px;
    padding: 6px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #1f2937;
}

#pse-cond-error {
    color: #b91c1c;
    font-size: 12px;
    min-height: 16px;
    margin: 6px 0;
}

#pse-cond-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

#pse-cond-actions button {
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

#pse-cond-actions button:first-child {
    background: #e5e7eb;
    color: #1f2937;
}

#pse-cond-actions button:last-child {
    background: #2563eb;
    color: #fff;
}

#pse-cond-actions button:last-child:disabled {
    opacity: 0.6;
    cursor: default;
}

/* Draft save/list modal */
#pse-draft-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000001;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

#pse-draft-modal {
    background: #fff;
    color: #1f2937;
    border-radius: 8px;
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#pse-draft-modal h3 {
    margin: 0 0 8px;
    font-size: 16px;
}

.pse-draft-help {
    color: #64748b;
    font-size: 12px;
    line-height: 1.4;
    margin-bottom: 16px;
}

.pse-draft-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
}

.pse-draft-field input {
    font-weight: normal;
    font-size: 13px;
    padding: 6px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #1f2937;
}

#pse-draft-error {
    color: #b91c1c;
    font-size: 12px;
    min-height: 16px;
    margin: 6px 0;
}

#pse-draft-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

#pse-draft-actions button {
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

#pse-draft-actions button:first-child {
    background: #e5e7eb;
    color: #1f2937;
}

#pse-draft-actions button:last-child {
    background: #2563eb;
    color: #fff;
}

#pse-draft-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 8px;
}

.pse-draft-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    flex-wrap: wrap;
}

.pse-draft-row-title {
    font-weight: 700;
    font-size: 13px;
    color: #1f2937;
}

.pse-draft-row-meta {
    font-size: 11px;
    color: #64748b;
    margin-top: 2px;
}

.pse-draft-row-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.pse-draft-row-actions button {
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    background: #e5e7eb;
    color: #1f2937;
}

.pse-draft-row-actions button.pse-draft-remove {
    background: #fee2e2;
    color: #b91c1c;
}

.pse-draft-row-actions button:disabled {
    opacity: 0.6;
    cursor: default;
}

/* ==========================================================================
   Gallery Browser Modal (Visual static/image file manager)
   ========================================================================== */

#pse-gallery-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000004;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-sizing: border-box;
}

#pse-gallery-modal {
    width: min(1200px, 98vw);
    height: min(840px, 92vh);
    background: #ffffff;
    color: #1f2937;
    border-radius: 10px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

.pse-gb-header {
    background: #1e293b;
    color: #f8fafc;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    border-bottom: 1px solid #334155;
}

.pse-gb-header h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #f8fafc;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pse-gb-header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pse-gb-search {
    background: #0f172a;
    color: #f8fafc;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    width: 170px;
    outline: none;
    transition: border-color 0.15s;
}

.pse-gb-search:focus {
    border-color: #3b82f6;
}

.pse-gb-og-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #cbd5e1;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    background: #0f172a;
    padding: 5px 9px;
    border-radius: 6px;
    border: 1px solid #334155;
}

.pse-gb-og-toggle input[type="checkbox"] {
    cursor: pointer;
    margin: 0;
}

.pse-gb-btn {
    border: 1px solid #475569;
    border-radius: 6px;
    padding: 6px 11px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    background: #334155;
    color: #f8fafc;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.pse-gb-btn:hover:not(:disabled) {
    background: #475569;
    border-color: #64748b;
}

.pse-gb-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.pse-gb-btn-primary {
    background: #2563eb;
    border-color: #1d4ed8;
    color: #ffffff;
}

.pse-gb-btn-primary:hover:not(:disabled) {
    background: #1d4ed8;
    border-color: #1e40af;
}

.pse-gb-btn-danger {
    background: #991b1b;
    border-color: #7f1d1d;
    color: #ffffff;
}

.pse-gb-btn-danger:hover:not(:disabled) {
    background: #b91c1c;
    border-color: #991b1b;
}

.pse-gb-btn-select {
    background: #16a34a;
    border-color: #15803d;
    color: #ffffff;
    font-size: 13px;
    padding: 8px 18px;
}

.pse-gb-btn-select:hover:not(:disabled) {
    background: #15803d;
}

.pse-gb-close {
    border: none;
    background: #475569;
    color: #f8fafc;
    border-radius: 6px;
    padding: 6px 11px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.pse-gb-close:hover {
    background: #64748b;
}

.pse-gb-layout {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

.pse-gb-sidebar {
    width: 240px;
    min-width: 200px;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pse-gb-sidebar-heading {
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    border-bottom: 1px solid #e2e8f0;
    background: #f1f5f9;
}

.pse-gb-tree {
    flex: 1;
    overflow-y: auto;
    padding: 8px 6px;
}

.pse-gb-tree-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 5px;
    font-size: 12px;
    color: #334155;
    cursor: pointer;
    user-select: none;
    margin-bottom: 2px;
    transition: background 0.12s, color 0.12s;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pse-gb-tree-item:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.pse-gb-tree-item.active {
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 700;
}

.pse-gb-tree-item.drag-over {
    background: #bbf7d0 !important;
    outline: 2px dashed #16a34a;
    color: #14532d !important;
}

.pse-gb-tree-icon {
    flex-shrink: 0;
    font-size: 14px;
}

.pse-gb-tree-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pse-gb-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #ffffff;
    min-width: 0;
}

.pse-gb-navbar {
    padding: 8px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
}

.pse-gb-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #64748b;
    overflow-x: auto;
    white-space: nowrap;
}

.pse-gb-crumb-up {
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #334155;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    margin-right: 6px;
}

.pse-gb-crumb-up:hover {
    background: #e2e8f0;
}

.pse-gb-crumb-link {
    color: #2563eb;
    cursor: pointer;
    font-weight: 600;
    padding: 2px 4px;
    border-radius: 3px;
}

.pse-gb-crumb-link:hover {
    background: #dbeafe;
    text-decoration: underline;
}

.pse-gb-crumb-sep {
    color: #94a3b8;
}

.pse-gb-crumb-current {
    color: #0f172a;
    font-weight: 700;
    padding: 2px 4px;
}

.pse-gb-stats {
    font-size: 11px;
    color: #64748b;
    flex-shrink: 0;
}

.pse-gb-grid-wrapper {
    flex: 1;
    position: relative;
    overflow-y: auto;
    padding: 16px;
    box-sizing: border-box;
    background: #fafafa;
}

.pse-gb-dropzone-overlay {
    position: absolute;
    inset: 10px;
    border: 3px dashed #2563eb;
    background: rgba(239, 246, 255, 0.94);
    border-radius: 8px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #1d4ed8;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}

.pse-gb-grid-wrapper.pse-gb-drag-active .pse-gb-dropzone-overlay {
    opacity: 1;
}

.pse-gb-dropzone-icon {
    font-size: 40px;
    margin-bottom: 8px;
}

.pse-gb-dropzone-text {
    font-size: 16px;
    font-weight: 700;
}

.pse-gb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
    gap: 12px;
}

.pse-gb-empty {
    grid-column: 1 / -1;
    padding: 60px 20px;
    text-align: center;
    color: #64748b;
    font-size: 13px;
}

.pse-gb-empty-icon {
    font-size: 38px;
    margin-bottom: 10px;
    opacity: 0.6;
}

.pse-gb-card {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
    user-select: none;
    position: relative;
}

.pse-gb-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #94a3b8;
}

.pse-gb-card.selected {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px #2563eb;
    background: #eff6ff;
}

.pse-gb-card.cut {
    opacity: 0.45;
    border-style: dashed;
}

.pse-gb-card.drag-over {
    background: #bbf7d0 !important;
    outline: 2px dashed #16a34a;
}

.pse-gb-card-folder {
    padding: 16px 12px;
    align-items: center;
    text-align: center;
}

.pse-gb-folder-icon {
    font-size: 38px;
    margin-bottom: 6px;
    line-height: 1;
}

.pse-gb-card-thumb {
    height: 105px;
    background: repeating-conic-gradient(#f1f5f9 0% 25%, #ffffff 0% 50%) 50% / 12px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    border-bottom: 1px solid #f1f5f9;
}

.pse-gb-card-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.2s;
}

.pse-gb-card:hover .pse-gb-card-thumb img {
    transform: scale(1.05);
}

.pse-gb-badge-og {
    position: absolute;
    top: 5px;
    left: 5px;
    background: #f59e0b;
    color: #ffffff;
    font-size: 9px;
    font-weight: 800;
    padding: 2px 5px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.pse-gb-edit-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.75);
    color: #f8fafc;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
}

.pse-gb-card-thumb:hover .pse-gb-edit-btn {
    opacity: 1;
}

.pse-gb-edit-btn:hover {
    background: #3b82f6;
}

.pse-gb-card-info {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.pse-gb-card-name {
    font-size: 11px;
    font-weight: 600;
    color: #1f2937;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pse-gb-card-meta {
    font-size: 10px;
    color: #64748b;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pse-gb-footer {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.pse-gb-status {
    font-size: 12px;
    color: #475569;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pse-gb-status.error {
    color: #b91c1c;
    font-weight: 600;
}

.pse-gb-footer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

@media (max-width: 768px) {
    #pse-gallery-modal {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }
    .pse-gb-sidebar {
        display: none;
    }
    .pse-gb-search {
        width: 130px;
    }
}
