body.oc-edit-mode [data-oc-item-id][data-oc-field] {
    cursor: text;
    outline: 1px dashed rgba(59, 130, 246, 0.35);
}

    body.oc-edit-mode [data-oc-item-id][data-oc-field]:hover {
        outline: 1px dashed rgba(59, 130, 246, 0.7);
        background-color: rgba(59, 130, 246, 0.04);
    }

    body.oc-edit-mode [data-oc-item-id][data-oc-field][contenteditable="true"] {
        outline: 2px solid rgba(59, 130, 246, 0.8);
        background-color: rgba(59, 130, 246, 0.06);
    }

#oc-align-toolbar button:hover {
    background: #f3f4f6 !important;
}

/* Media field wrapper */
body.oc-edit-mode .oc-media-editable {
    position: relative;
    /* Do NOT set display here — .align-* flex rules in wysiwyg-utilities.css
       control the wrapper's display. Overriding display here breaks flex
       centering when edit mode is active. */
    cursor: pointer;
}

    body.oc-edit-mode .oc-media-editable img {
        /* Do NOT force display:block here — it overrides display:flex on .align-center wrappers.
           The img is already a replaced element; block/inline distinction is handled by the wrapper. */
        transition: opacity 0.2s ease;
    }

    body.oc-edit-mode .oc-media-editable:hover img {
        opacity: 0.7;
    }

    body.oc-edit-mode .oc-media-editable .oc-media-overlay {
        position: absolute;
        inset: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        opacity: 0;
        transition: opacity 0.2s ease;
        background: rgba(0, 0, 0, 0.35);
        color: #fff;
        font: 600 13px/1.4 sans-serif;
        pointer-events: none;
        border-radius: 2px;
    }

    body.oc-edit-mode .oc-media-editable .oc-media-overlay-icon {
        font-size: 20px;
        line-height: 1;
    }

    body.oc-edit-mode .oc-media-editable:hover .oc-media-overlay {
        opacity: 1;
    }

/* ── BagPart child delete button ─────────────────────────────────────────── */

/*
 * The delete button is injected by _renderDeleteButtons() into every element
 * that carries both data-oc-parent-id and data-oc-item-id (i.e. BagPart children).
 * It is absolutely positioned in the top-right corner of the container and is
 * only visible when the container is hovered in edit mode.
 */
.oc-delete-btn {
    display: none; /* hidden by default; shown only in edit mode via rule below */
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 100;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid rgba(220, 38, 38, 0.5);
    border-radius: 4px;
    background: rgba(254, 226, 226, 0.9);
    color: #b91c1c;
    font: 600 14px/1 sans-serif;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease;
    pointer-events: none;
}

body.oc-edit-mode .oc-delete-btn {
    display: flex;
    pointer-events: auto;
}

body.oc-edit-mode [data-oc-parent-id][data-oc-item-id]:hover .oc-delete-btn {
    opacity: 1;
}

.oc-delete-btn:hover {
    background: rgba(220, 38, 38, 0.15) !important;
    border-color: #b91c1c !important;
}

/* ── Alignment utility classes ───────────────────────────────────────────── */

/* align-left/center/right are defined in wysiwyg-utilities.css as flex rules.
   Removed text-align overrides from here to avoid cascade conflicts. */
/* ── Theme Assistant Panel ───────────────────────────────────────────────── */
#oc-theme-assistant {
    position: fixed;
    top: 80px;
    right: 24px;
    width: 1160px;
    max-height: 80vh;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    z-index: 9995;
    font-family: sans-serif;
    font-size: 13px;
        overflow: hidden;
    transition: width 0.15s ease, box-shadow 0.15s ease;
}

    #oc-theme-assistant.theme-panel-hidden {
        display: none;
    }

    /* Keep a small, draggable header visible so collapse can be reversed without
       leaving edit mode or clearing the active item/chat context. */
    #oc-theme-assistant.oc-theme-collapsed {
        width: 270px;
        max-height: none;
    }

    #oc-theme-assistant.oc-theme-collapsed #oc-theme-panel-content {
        display: none;
    }

    #oc-theme-assistant.oc-theme-collapsed #oc-theme-header {
        border-bottom: none;
        border-radius: 10px;
    }

#oc-theme-panel-content {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
}

/* Header — drag handle */
#oc-theme-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    padding: 10px 14px;

    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 10px 10px 0 0;
    cursor: grab;
    user-select: none;
}

#oc-theme-assistant.oc-dragging #oc-theme-header {
    cursor: grabbing;
}

#oc-theme-header h4 {
    grid-column: 1;
    justify-self: start;
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
}

#oc-theme-collapse {
    grid-column: 2;
    width: 26px;
    height: 24px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}

#oc-theme-close {
    grid-column: 3;
    justify-self: end;
    width: 26px;
    height: 24px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    font-size: 18px;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
}

    #oc-theme-collapse:hover,
    #oc-theme-close:hover {
        background: #e2e8f0;
        color: #1e293b;
    }

    #oc-theme-collapse:focus-visible,
    #oc-theme-close:focus-visible {
        outline: 2px solid #2563eb;
        outline-offset: 1px;
    }

/* Tabs */
#oc-theme-tabs {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
}

    #oc-theme-tabs button {
        flex: 1;
        padding: 8px 0;
        border: none;
        border-bottom: 2px solid transparent;
        background: none;
        font-size: 12px;
        font-weight: 500;
        color: #64748b;
        cursor: pointer;
        transition: color 0.15s, border-color 0.15s;
    }

        #oc-theme-tabs button.active {
            color: #2563eb;
            border-bottom-color: #2563eb;
            font-weight: 600;
        }

/* Body — scrollable */
#oc-theme-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
}

.theme-tab {
    display: none;
}

    .theme-tab.active {
        display: block;
    }

/* Manual tuning groups */
.manual-state-banner {
    font-size: 11px;
    color: #64748b;
    background: #f1f5f9;
    border-radius: 4px;
    padding: 5px 8px;
    margin-bottom: 10px;
    word-break: break-all;
}

.control-group {
    margin-bottom: 12px;
}

    .control-group label {
        display: block;
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #94a3b8;
        margin-bottom: 6px;
    }

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.theme-toggle-btn {
    padding: 4px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #fff;
    font-size: 12px;
    color: #334155;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s, color 0.1s;
    white-space: nowrap;
}

    .theme-toggle-btn:hover {
        background: #f1f5f9;
        border-color: #94a3b8;
    }

    .theme-toggle-btn.active {
        background: #2563eb;
        border-color: #2563eb;
        color: #fff;
    }

/* AI tab — only flex when active; the base .theme-tab rule hides it otherwise */
#tab-ai.active {
    display: flex;
    flex-direction: column;
    height: 100%;
}

#ai-chat-history {
    flex: 1;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 8px;
    font-size: 13px;
    color: #cbd5e1;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 4px;
    padding: 10px;
}

.chat-message {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #1e293b;
    line-height: 1.4;
}

    .chat-message:last-child {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }

/* AI responses are rendered from Markdown with DOM nodes rather than untrusted
   HTML. These styles keep richer output compact and legible in the panel. */
.chat-markdown {
    overflow-wrap: anywhere;
}

.chat-markdown > :first-child {
    margin-top: 0;
}

.chat-markdown > :last-child {
    margin-bottom: 0;
}

.chat-markdown h1,
.chat-markdown h2,
.chat-markdown h3,
.chat-markdown h4,
.chat-markdown h5,
.chat-markdown h6 {
    color: #f8fafc;
    line-height: 1.25;
    margin: 14px 0 7px;
}

.chat-markdown h1 { font-size: 17px; }
.chat-markdown h2 { font-size: 15px; }
.chat-markdown h3,
.chat-markdown h4,
.chat-markdown h5,
.chat-markdown h6 { font-size: 13px; }

.chat-markdown p {
    margin: 0 0 9px;
}

.chat-markdown ul,
.chat-markdown ol {
    margin: 0 0 10px;
    padding-left: 20px;
}

.chat-markdown li + li {
    margin-top: 3px;
}

.chat-markdown strong {
    color: #f8fafc;
}

.chat-markdown em {
    color: #cbd5e1;
}

.chat-markdown code {
    display: inline;
    padding: 1px 4px;
    border: 1px solid #475569;
    border-radius: 3px;
    background: #0f172a;
    color: #bfdbfe;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.92em;
    white-space: break-spaces;
}

.chat-markdown .oc-chat-code-block {
    overflow-x: auto;
    margin: 0 0 10px;
    padding: 9px;
    border: 1px solid #475569;
    border-radius: 4px;
    background: #020617;
    color: #e2e8f0;
    white-space: pre;
}

.chat-markdown .oc-chat-code-block code {
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    white-space: inherit;
}

.chat-markdown .oc-chat-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    margin: 0 0 10px;
    border: 1px solid #475569;
    border-radius: 4px;
}

.chat-markdown .oc-chat-markdown-table {
    width: 100%;
    min-width: 360px;
    border-collapse: collapse;
    font-size: 12px;
}

.chat-markdown .oc-chat-markdown-table th,
.chat-markdown .oc-chat-markdown-table td {
    padding: 6px 7px;
    border-bottom: 1px solid #475569;
    text-align: left;
    vertical-align: top;
}

.chat-markdown .oc-chat-markdown-table th {
    background: #1e293b;
    color: #f8fafc;
    font-weight: 600;
}

.chat-markdown .oc-chat-markdown-table tr:last-child td {
    border-bottom: 0;
}

.chat-markdown .oc-chat-markdown-table tbody tr:nth-child(even) {
    background: rgba(15, 23, 42, 0.45);
}

.chat-markdown blockquote {
    margin: 0 0 10px;
    padding: 7px 10px;
    border-left: 3px solid #38bdf8;
    background: rgba(15, 23, 42, 0.45);
    color: #cbd5e1;
}

.chat-markdown a {
    color: #7dd3fc;
    text-decoration: underline;
}

.chat-markdown hr {
    margin: 12px 0;
    border: 0;
    border-top: 1px solid #475569;
}

.chat-user strong {

    color: #93c5fd;
}

.chat-ai strong {
    color: #2dd4bf;
}

.chat-system strong {
    color: #f87171;
    font-style: italic;
}

.ai-input-area {
    display: flex;
    gap: 6px;
}

    .ai-input-area input {
        flex: 1;
        padding: 8px 10px;
        border: 1px solid #cbd5e1;
        border-radius: 4px;
        font-size: 13px;
    }

    .ai-input-area button {
        padding: 8px 14px;
        background: #2563eb;
        color: #fff;
        border: none;
        border-radius: 4px;
        cursor: pointer;
        font-size: 13px;
    }

        .ai-input-area button:disabled {
            background: #94a3b8;
            cursor: not-allowed;
        }

/* Highlight target element */
.oc-theme-active-target {
    outline: 2px dashed #2563eb !important;
    outline-offset: 2px;
}

.manual-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 20px;
    align-items: start;
}

/* ── Children strip ─────────────────────────────────────────────────────── */
#manual-children-strip {
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

/* ── Navigator tree (Tab 3) ─────────────────────────────────────────────── */
#oc-nav-tree {
    padding: 4px 0;
    font-size: 12px;
}

.oc-nav-node {
    user-select: none;
}

.oc-nav-row {
    display: flex;
    align-items: center;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: default;
    transition: background 0.1s;
}

    .oc-nav-row:hover {
        background: #f1f5f9;
    }

    .oc-nav-row.oc-nav-active {
        background: #eff6ff;
        outline: 1px solid #bfdbfe;
    }

.oc-nav-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

    .oc-nav-label:hover {
        color: #2563eb;
        text-decoration: underline;
    }

.oc-nav-children {
    /* children are always visible by default; collapsed via JS */
}



/* ── Reorder sortable list ──────────────────────────────────────────────── */
.oc-reorder-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.oc-reorder-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    border-radius: 4px;
    background: #fff;
    border: 1px solid transparent;
    transition: background 0.1s, border-color 0.1s;
    cursor: default;
    user-select: none;
}

    .oc-reorder-row:hover {
        background: #f8fafc;
        border-color: #e2e8f0;
    }

    .oc-reorder-row.oc-reorder-dragging {
        opacity: 0.4;
    }

    .oc-reorder-row.oc-reorder-over {
        border-color: #2563eb;
        background: #eff6ff;
    }

/* Drag handle (≡) */
.oc-reorder-handle {
    cursor: grab;
    color: #94a3b8;
    font-size: 14px;
    padding: 0 2px;
    flex-shrink: 0;
}

    .oc-reorder-handle:active {
        cursor: grabbing;
    }

/* Up / Down / Expand arrow buttons */
.oc-reorder-arrow {
    background: none;
    border: none;
    padding: 0 2px;
    font-size: 10px;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
    flex-shrink: 0;
}

    .oc-reorder-arrow:hover {
        color: #2563eb;
    }

/* Row label */
.oc-reorder-label {
    flex: 1;
    font-size: 12px;
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

    .oc-reorder-label:hover {
        color: #2563eb;
        text-decoration: underline;
    }

/* Strip section header */
.oc-strip-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #94a3b8;
    margin-bottom: 5px;
}

/* ── Empty rich-text field affordance ────────────────────────────────────── */

/* An evolved HtmlField may have no persisted value yet. Keep it invisible in
   normal rendering, but expose a stable editor target without injecting text
   into the field's actual HTML value. */
body.oc-edit-mode [data-oc-empty-html="true"] {
    position: relative;
    min-height: 2.5rem;
    padding: 0.5rem 0.625rem;
    border: 1px dashed rgba(100, 116, 139, 0.65);
    border-radius: 0.25rem;
    color: #64748b;
}

body.oc-edit-mode [data-oc-empty-html="true"]::before {
    content: attr(data-oc-empty-label);
    font: italic 0.875rem/1.5 sans-serif;
    color: inherit;
    pointer-events: none;
}

body.oc-edit-mode [data-oc-empty-html="true"][contenteditable="true"]::before {
    content: "";
}

/* ── Model B collection editor ───────────────────────────────────────────── */
.oc-manage-collection-btn {
    display: none;
}

body.oc-edit-mode .oc-collection {
    position: relative;
}

body.oc-edit-mode .oc-manage-collection-btn {
    display: inline-flex !important;
    align-items: center;
    margin-top: 10px;
    padding: 5px 9px;
    border: 1px solid #93c5fd;
    border-radius: 4px;
    background: #eff6ff;
    color: #1d4ed8;
    font: 600 12px/1.2 sans-serif;
    cursor: pointer;
}

body.oc-edit-mode .oc-manage-collection-btn:hover {
    background: #dbeafe;
    border-color: #60a5fa;
}

.oc-collection-empty {
    color: #64748b;
    font: italic 0.9rem/1.5 sans-serif;
}

.oc-collection-editor-empty {
    color: #64748b;
    font-size: 12px;
    line-height: 1.5;
}

.oc-collection-editor__header {
    margin-bottom: 10px;
    color: #475569;
    font-size: 12px;
    line-height: 1.45;
}

.oc-collection-editor__heading {
    margin: 0 0 4px;
    color: #1e293b;
    font-size: 13px;
    font-weight: 600;
}

.oc-collection-editor__error {
    margin: 0 0 10px;
    padding: 7px 8px;
    border: 1px solid #fecaca;
    border-radius: 4px;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 12px;
}

.oc-collection-editor__section + .oc-collection-editor__section {
    margin-top: 14px;
}

.oc-collection-editor__label {
    display: block;
    margin-bottom: 5px;
    color: #64748b;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.oc-collection-editor__list {
    display: grid;
    gap: 5px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.oc-collection-editor__row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding: 6px 7px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: #fff;
}

.oc-collection-editor__name {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    color: #1e293b;
    font-size: 12px;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.oc-collection-editor__type {
    overflow: hidden;
    max-width: 90px;
    color: #64748b;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.oc-collection-editor__button {
    flex: 0 0 auto;
    padding: 3px 6px;
    border: 1px solid #cbd5e1;
    border-radius: 3px;
    background: #fff;
    color: #334155;
    font-size: 11px;
    cursor: pointer;
}

.oc-collection-editor__button:hover:not(:disabled) {
    border-color: #60a5fa;
    color: #1d4ed8;
}

.oc-collection-editor__button--danger:hover:not(:disabled) {
    border-color: #fca5a5;
    color: #b91c1c;
}

.oc-collection-editor__button:disabled {
    cursor: not-allowed;
    opacity: .45;
}

.oc-collection-editor__empty {
    margin: 0;
    color: #64748b;
    font-size: 12px;
}

.oc-collection-editor__status {
    min-height: 18px;
    margin-top: 10px;
    color: #475569;
    font-size: 11px;
}

.oc-collection-editor__status.is-error {
    color: #b91c1c;
}

@media (max-width: 720px) {
    #oc-theme-assistant {
        right: 12px;
        left: 12px;
        width: auto;
    }

    .oc-collection-editor__type {
        display: none;
    }
}
