/* ============================================
   Canvas Editor Styles — Light Theme, Creatopy-inspired
   ============================================ */

/* --- Editor Layout --- */
.editor-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-primary);
}

.editor-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.editor-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 16px;
    color: var(--text-secondary);
}

/* --- Toolbar --- */
.editor-toolbar {
    height: var(--toolbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
}

.toolbar-left,
.toolbar-center,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 6px;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 12px;
    transition: all var(--transition);
}

.toolbar-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.toolbar-btn.active { background: var(--accent-subtle); color: var(--accent); }

/* --- Propagate Toggle --- */
.toolbar-propagate-wrap {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    position: relative;
}

.toolbar-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.toolbar-toggle:hover {
    border-color: var(--accent);
}
.toolbar-toggle.active {
    background: var(--accent-subtle);
    color: var(--accent);
    border-color: var(--accent);
}
.toolbar-toggle:not(.active) {
    background: var(--bg-surface);
    color: var(--text-secondary);
}

.toggle-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.toggle-indicator.on {
    background: var(--accent);
    box-shadow: 0 0 5px rgba(99, 102, 241, 0.5);
}
.toggle-indicator.off {
    background: var(--text-muted);
    opacity: 0.5;
}

.toolbar-toggle-text {
    font-size: 12px;
    letter-spacing: 0.2px;
}

/* Info icon */
.toolbar-propagate-info {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--transition);
}
.toolbar-propagate-info:hover {
    color: var(--accent);
}

/* Popover */
.propagate-popover {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 310px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 14px 16px;
    z-index: 200;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-primary);
}
.propagate-popover.visible {
    display: block;
}
.propagate-popover::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 14px;
    width: 10px;
    height: 10px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    border-top: 1px solid var(--border);
    transform: rotate(45deg);
}
.propagate-popover-title {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
}
.propagate-popover-section {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-subtle);
}
.propagate-popover-section:last-of-type {
    border-bottom: none;
    margin-bottom: 6px;
    padding-bottom: 0;
}
.propagate-popover-section p {
    margin: 4px 0 0;
    color: var(--text-secondary);
    font-size: 11.5px;
}
.propagate-popover-section em {
    color: var(--text-primary);
    font-style: normal;
    font-weight: 500;
}
.pop-on {
    color: var(--accent);
}
.pop-off {
    color: var(--text-secondary);
}
.propagate-popover-hint {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 6px 8px;
    border-radius: var(--radius-sm);
}

.toolbar-push-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--accent-subtle);
    color: var(--accent);
    border: 1px solid transparent;
    font-weight: 600;
}
.toolbar-push-btn:hover {
    background: var(--accent);
    color: #fff;
}

/* --- Push Changes Modal --- */
.push-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(3px);
}
.push-modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    width: 400px;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.push-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle);
}
.push-modal-header h3 {
    font-size: 15px;
    font-weight: 600;
}
.push-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 18px;
}
.push-modal-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 24px 0;
}
.push-quick-select {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.push-quick-select .btn {
    font-size: 11px;
    padding: 3px 10px;
}
.push-group-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin: 10px 0 4px 0;
}
.push-size-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 4px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
}
.push-size-row:hover {
    background: var(--bg-hover);
}
.push-size-row input[type="checkbox"] {
    accent-color: var(--accent);
    width: 15px;
    height: 15px;
    cursor: pointer;
}
.push-size-label {
    font-weight: 500;
    min-width: 90px;
}
.push-size-name {
    color: var(--text-secondary);
    font-size: 12px;
}
.push-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid var(--border-subtle);
}

.toolbar-separator {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 6px;
}

.zoom-label {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 42px;
    text-align: center;
    font-weight: 500;
}

.design-name-input {
    background: none;
    border: 1px solid transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    outline: none;
    width: 220px;
}

.design-name-input:hover { border-color: var(--border); }
.design-name-input:focus { border-color: var(--accent); }

.size-selector {
    padding: 5px 10px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font: inherit;
    font-size: 12px;
    outline: none;
    max-width: 200px;
}

.size-selector:focus { border-color: var(--accent); }

/* --- Left Panel --- */
/* --- Left Panel: Icon Bar + Slide-out Panel (Creatopy-style) --- */
.left-panel {
    display: flex;
    flex-shrink: 0;
    height: 100%;
}

/* Narrow icon sidebar */
.icon-bar {
    width: var(--icon-bar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    z-index: 10;
}
.icon-bar-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    padding-top: 4px;
}
.icon-bar-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 8px;
}
.icon-bar-btn {
    width: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 0 6px;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    font: inherit;
    font-size: 9px;
    font-weight: 500;
    transition: all var(--transition);
    border-radius: 6px;
    margin: 1px 0;
    position: relative;
}
.icon-bar-btn:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.icon-bar-btn.active {
    color: var(--accent);
    background: rgba(99, 102, 241, 0.08);
}
.icon-bar-btn.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}
.icon-bar-btn svg { flex-shrink: 0; }

/* Slide-out content panel */
.slide-panel {
    width: 0;
    overflow: hidden;
    background: var(--bg-primary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease;
}
.slide-panel.open {
    width: var(--left-panel-width);
}
.slide-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    min-height: 48px;
}
.slide-panel-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.tab-panel {
    display: none;
    padding: 12px;
}

.tab-panel.active { display: block; }

.panel-empty-text {
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
    padding: 20px 0;
}

/* --- Insert Panel --- */
.insert-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    margin-bottom: 12px;
    color: var(--text-muted);
}

.insert-search input {
    flex: 1;
    border: none;
    background: none;
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    outline: none;
}

.insert-search input::placeholder { color: var(--text-muted); }

.insert-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--radius);
    font: inherit;
    font-size: 13px;
    text-align: left;
    transition: all var(--transition);
    margin-bottom: 6px;
}

.insert-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.insert-btn svg { color: var(--text-muted); flex-shrink: 0; }

.insert-section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 16px 0 8px;
}

.shapes-row {
    display: flex;
    gap: 6px;
}

/* ── Catalog template mode (product-feed-bound layers) ─────────────────────── */
/* Principle-of-work hint at the top of the product insert section. */
.tpl-principle {
    font-size: 11.5px;
    line-height: 1.5;
    color: #4b4570;
    background: #f6f5ff;
    border: 1px solid #e7e3fb;
    border-radius: 8px;
    padding: 9px 11px;
    margin-bottom: 10px;
}
.tpl-principle strong { color: #5b4ec4; }
/* Preview-product picker — cycle real feed products. */
.tpl-preview-pick { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; background: #f5f5fa; border: 1px solid var(--border-color, #e5e7eb); border-radius: 8px; padding: 6px; }
.tpl-preview-label { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.tpl-preview-sel {
    width: 100%; font-size: 12px; padding: 7px 9px; border: 1px solid var(--border-color, #dcdfe6);
    border-radius: 8px; background: #fff; color: var(--text-strong, #1f2430); box-sizing: border-box;
}
.tpl-preview-sel:focus { outline: none; border-color: #8b7cf6; box-shadow: 0 0 0 3px rgba(139,124,246,.14); }

/* ── Searchable, image-rich product picker (Preview product) ───────────────── */
.cb-psp { position: relative; width: 100%; }
.cb-psp-trigger {
    width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
    padding: 7px 9px; border: 1px solid var(--border-color, #dcdfe6); border-radius: 9px;
    background: #fff; cursor: pointer; box-sizing: border-box; transition: border-color .12s, box-shadow .12s;
    font-family: inherit;
}
.cb-psp-trigger:hover, .cb-psp.is-open .cb-psp-trigger { border-color: #8b7cf6; }
.cb-psp.is-open .cb-psp-trigger { box-shadow: 0 0 0 3px rgba(139,124,246,.14); }
.cb-psp-thumb {
    flex: 0 0 auto; width: 40px; height: 40px; border-radius: 7px; overflow: hidden;
    background: #f1f1f4 url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="%23b8bcc6" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>') center/16px no-repeat;
}
.cb-psp-thumb img, .cb-psp-rthumb img { width: 100%; height: 100%; object-fit: contain; display: block; background: #fff; }
.cb-psp-lbl { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cb-psp-title { font-size: 13px; font-weight: 600; color: var(--text-strong, #1f2430); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-psp-id { font-size: 11px; color: var(--text-muted, #8b90a0); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-psp-caret { flex: 0 0 auto; color: #646B78; font-size: 11px; }

/* Price + discount (trigger and rows). */
.cb-psp-price, .cb-psp-rprice { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 7px; margin-top: 2px; font-size: 12px; font-variant-numeric: tabular-nums; }
.cb-psp-now { font-weight: 700; color: #1f2430; }
.cb-psp-now.is-sale { color: #c2410c; }
.cb-psp-was { color: #646B78; text-decoration: line-through; }
.cb-psp-off {
    font-size: 11px; font-weight: 700; color: #fff; background: #e5484d;
    border-radius: 5px; padding: 1px 6px; line-height: 1.45;
}

/* The list floats on <body> (position:fixed, placed by JS) so it is never clipped to the panel. */
.cb-psp-panel {
    position: fixed; z-index: 10060;
    display: none; flex-direction: column;
    border: 1px solid var(--border-color, #e5e7eb); border-radius: 12px;
    background: #fff; box-shadow: 0 18px 44px rgba(15,23,42,.20); overflow: hidden;
    font-family: var(--font-sans, 'IBM Plex Sans', system-ui, sans-serif);
    box-sizing: border-box;
}
.cb-psp-input {
    flex: 0 0 auto; width: 100%; border: none; border-bottom: 1px solid var(--border-color, #eee);
    padding: 12px 14px; font-size: 14px; box-sizing: border-box; background: #fff; font-family: inherit;
}
.cb-psp-input:focus { outline: none; box-shadow: inset 0 -2px 0 #8b7cf6; }
.cb-psp-filters {
    flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; padding: 8px 14px;
    border-bottom: 1px solid var(--border-color, #f0f0f3);
}
.cb-psp-stock {
    display: flex; align-items: center; gap: 7px; font-size: 13px;
    color: var(--text-muted, #6b7280); cursor: pointer;
}
.cb-psp-stock input { accent-color: #8b7cf6; margin: 0; width: 15px; height: 15px; }
.cb-psp-results { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 4px; }
.cb-psp-msg { padding: 18px 12px; text-align: center; font-size: 13px; color: var(--text-muted, #9aa0b0); }
.cb-psp-row {
    width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
    padding: 8px 10px; border: none; background: transparent; cursor: pointer; border-radius: 9px;
    font-family: inherit; box-sizing: border-box;
}
.cb-psp-row + .cb-psp-row { margin-top: 2px; }
.cb-psp-row:hover { background: #f6f5ff; }
.cb-psp-row.is-current { background: #eef2ff; box-shadow: inset 0 0 0 1px #d9d5fb; }
.cb-psp-rthumb {
    flex: 0 0 auto; width: 52px; height: 52px; border-radius: 8px; overflow: hidden; background: #f1f1f4;
    border: 1px solid #eef0f3;
}
.cb-psp-rinfo { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cb-psp-rtitle {
    font-size: 13.5px; font-weight: 600; color: var(--text-strong, #1f2430); line-height: 1.3;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word;
}
.cb-psp-rid { font-size: 12px; color: var(--text-muted, #8b90a0); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-psp-rside { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; width: 16px; }
.cb-psp-rdot { width: 9px; height: 9px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.16); }
.cb-psp-rdot.is-out { background: #d1d5db; box-shadow: 0 0 0 3px rgba(156,163,175,.16); }
.insert-sample-hint {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-subtle, #f3f4f6);
    border-radius: 6px;
    padding: 6px 8px;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cb-binding-section { border-bottom: 1px solid var(--border-color, #e5e7eb); }
.cb-binding-hint {
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-muted);
    margin-top: 6px;
}
/* Bound-field tag — a pill showing WHICH feed field a layer renders, so image
   layers showing real sample art are still identifiable at a glance. */
.cb-field-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    color: #5b4ec4;
    background: #f1efff;
    border: 1px solid #e2dcfb;
    border-radius: 999px;
    padding: 3px 9px;
    margin: 2px 0 9px;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cb-field-tag-fx { color: #b4640a; background: #fff4e6; border-color: #ffe2bf; margin: 8px 0 2px; }
/* Element fit/safe-area controller (right panel) */
.cb-fit-label { font-size: 11px; font-weight: 600; color: var(--text-muted, #6b7280); margin: 10px 0 6px; }
.cb-fit-align {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    max-width: 132px;
}
.cb-fit-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 30px;
    font-size: 14px;
    line-height: 1;
    color: #4b5563;
    background: #f4f4f6;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 7px;
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
}
.cb-fit-cell:hover { background: #ecebfe; border-color: #d8d2fb; }
.cb-fit-cell.active { background: #8b7cf6; border-color: #8b7cf6; color: #fff; }
.cb-fit-cell.cb-fit-spacer { background: transparent; border: none; cursor: default; pointer-events: none; }
/* Single-row H/V alignment: 3 horizontal + divider + 3 vertical, equal width. */
.cb-fit-align-row { display: flex; align-items: stretch; gap: 5px; }
.cb-fit-align-row .cb-fit-cell { flex: 1 1 0; min-width: 0; padding: 0; }
.cb-fit-align-row .cb-fit-cell svg { width: 16px; height: 16px; }
.cb-fit-div { flex: 0 0 1px; align-self: stretch; min-height: 22px; background: var(--border-color, #e5e7eb); margin: 0 2px; }
/* "Long text handling" docked at the TOP of the Typography section — flatten the
   nested panel-section so it reads as part of Typography (no extra box/border). */
.panel-section .cb-fit-in-typo { padding: 0; border-bottom: 0; margin: 0 0 12px; }
.panel-section .cb-fit-in-typo > h3 { margin-top: 0; }

/* Quick-action toolbar (template mode, just under Preview): z-order + lock + show/hide. */
.cb-quickbar-section { padding: 10px 12px; }
.cb-quickbar { display: flex; align-items: center; gap: 6px; }
.cb-quickbar .cb-qspacer { flex: 1 1 auto; }   /* pushes lock + show/hide to the right */
.cb-qbtn {
    width: 34px; height: 34px; flex: 0 0 auto;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border-color, #e5e7eb); border-radius: 8px;
    background: #fff; color: var(--text-muted, #6b7280); cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
}
.cb-qbtn:hover { background: #f7f7fb; color: var(--text-strong, #1f2430); border-color: #d8d2fb; }
.cb-qbtn.is-on  { background: #8b7cf6; border-color: #8b7cf6; color: #fff; }   /* locked */
.cb-qbtn.is-off { color: #c0504d; border-color: #e2a3a3; background: #fdf3f3; } /* hidden */

/* Quickbar ⋯ overflow menu (Duplicate / Save to Brand Kit / Delete). */
.cb-qmore { position: relative; }
.cb-qmenu {
    position: absolute; top: calc(100% + 4px); right: 0; z-index: 50;
    min-width: 168px; background: #fff; border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 10px; box-shadow: 0 10px 28px rgba(17, 24, 39, .16); padding: 5px;
}
.cb-qmenu-item {
    display: block; width: 100%; text-align: left; padding: 8px 10px; font-size: 13px;
    border: 0; border-radius: 6px; background: transparent; color: var(--text-strong, #1f2430); cursor: pointer;
}
.cb-qmenu-item:hover { background: #f3f4f8; }
.cb-qmenu-item.danger { color: #d05a5a; }
.cb-qmenu-item.danger:hover { background: #fdf3f3; }

/* Collapsible panel section (e.g. image Filter Presets) — click the heading to toggle. */
.cb-collapse-head { display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none; margin-bottom: 0 !important; }
.cb-collapsible:not(.is-collapsed) .cb-collapse-head { margin-bottom: 10px !important; }
.cb-collapse-caret { font-size: 10px; color: var(--text-muted, #9aa1ad); margin-left: 8px; }
/* Collapsed section: hide everything except the (clickable) heading. */
.cb-collapsible.is-collapsed > *:not(.cb-collapse-head) { display: none; }
/* Design / Visibility tab buttons — icon + label, clearly suggestive. */
.cb-rtab { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
/* Motion tab dot — the selected layer already animates (edit, not add). */
.cb-rtab-dot {
    display: inline-block; width: 5px; height: 5px; border-radius: 50%;
    background: #5B53E8; margin-left: 4px; vertical-align: 2px;
}
.cb-rtab svg { flex: 0 0 auto; opacity: .85; }
/* Layer visibility rules (Dotidot-style conditions, AND) */
.cb-cond-status {
    font-size: 11.5px;
    font-weight: 600;
    border-radius: 7px;
    padding: 6px 9px;
    margin: 2px 0 9px;
}
.cb-cond-status.ok { color: #0a7d4b; background: #e9f9f0; border: 1px solid #c7eed9; }
.cb-cond-status.no { color: #b4640a; background: #fff4e6; border: 1px solid #ffe2bf; }
/* Aggregate "N of M products" — the REAL whole-feed count for frame / layer / gate rules is the
   condition component's STANDARD count line (.cnd-count, css/rules.css). Only the narrow right
   panel's fit lives here: the sentence wraps instead of overflowing, and the tooltip says why. */
.cb-cond-section .cnd-count--group { margin: 8px 0 10px 2px; }
.cb-cond-section .cb-mc { cursor: help; line-height: 1.4; }
/* Hide-when-empty default toggle (bound layers) */
.cb-hideempty-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text, #374151); margin: 2px 0 10px; cursor: pointer; line-height: 1.35; }
.cb-hideempty-row input { width: 14px; height: 14px; flex-shrink: 0; cursor: pointer; accent-color: #5B53E8; }
/* ── Visibility rules — automations bracket builder (css/rules.css) fitted to the
   ~300px right panel. The group's op pill folds the old "Show when All/Any match"
   toggle (AND ↔ OR). These rules only resize the shared builder for the narrow
   column: each leaf wraps to two lines (field on top; operator + value + × below)
   so nothing overflows. The base look stays shared with the rule builder + smart
   labels — see memory: condition-builder-design.md. ── */
.cb-cond-section .rules-conditions { margin: 2px 0; }
.cb-cond-section .rules-leaf { flex-wrap: wrap; gap: 6px 8px; padding: 8px 10px; }
.cb-cond-section .rules-leaf__metric,
.cb-cond-section .rules-leaf--property .rules-leaf__metric { flex: 1 1 auto; min-width: 130px; }
.cb-cond-section .rules-leaf__op,
.cb-cond-section .rules-leaf--property .rules-leaf__op { flex: 0 1 auto; min-width: 88px; }
.cb-cond-section .rules-leaf__value-input--string { flex: 1 1 70px; width: auto; min-width: 60px; }
.cb-cond-section .rules-leaf__del { flex: 0 0 auto; margin-left: auto; }
/* No conditions yet → a single filled "Add condition" button (no empty bracket). */
/* (.cnd-add0 is the shared component's empty-state bar — js/shared/conditions.js.) */
.cb-cond-section .cb-cond-add0,
.cb-cond-section .cnd-add0 { padding-left: 0; margin-top: 2px; }
.cb-cond-section .cb-cond-add0 .rules-group__add-btn,
.cb-cond-section .cnd-add0 .rules-group__add-btn { width: 100%; justify-content: center; }
/* Right-panel Design | Visibility tabs (template mode) */
.cb-rtab-bar {
    display: flex; gap: 5px; justify-content: center;
    padding: 10px 14px 12px; margin-bottom: 4px;   /* horizontal padding insets + centers the two tabs */
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}
.cb-rtab {
    flex: 1; padding: 7px 10px; font-size: 12px; font-weight: 600;
    color: var(--text-muted, #6b7280); background: #f4f4f6;
    border: 1px solid var(--border-color, #e5e7eb); border-radius: 8px;
    cursor: pointer; transition: background .12s, color .12s, border-color .12s;
}
.cb-rtab:hover { background: #ecebfe; border-color: #d8d2fb; }
.cb-rtab.active { background: #8b7cf6; color: #fff; border-color: #8b7cf6; }
.cb-rtab-pane { display: block; }
/* Product-tag hover preview tooltip (>750ms hover on a Product-tags button) */
.cb-tag-preview {
    position: fixed; z-index: 100000; max-width: 240px; display: none;
    background: #fff; border: 1px solid var(--border-color, #e5e7eb); border-radius: 10px;
    box-shadow: 0 10px 34px rgba(0,0,0,.18); padding: 10px 12px; pointer-events: none;
}
.cb-tag-preview-head { font-weight: 700; font-size: 12px; color: #111827; margin-bottom: 6px; }
.cb-tag-preview-val { font-size: 13px; color: #1f2937; word-break: break-word; line-height: 1.35; }
.cb-tag-preview-img { display: block; max-width: 216px; max-height: 180px; border-radius: 6px; background: #f4f4f6; object-fit: contain; }
.cb-tag-preview-sub { margin-top: 6px; font-size: 10.5px; color: #646B78; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
/* Templates browser popup (left "Templates" button, template mode) */
.cb-tpl-pop {
    width: 92vw; max-width: 1280px; height: 88vh; max-height: 900px;
    background: #fff; border-radius: 14px; display: flex; flex-direction: column;
    overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.cb-tpl-pop-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--border-color, #e5e7eb); }
.cb-tpl-pop-head h2 { margin: 0; font-size: 18px; }
.cb-tpl-pop-headactions { display: flex; align-items: center; gap: 12px; }
.cb-tpl-pop-filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 22px; border-bottom: 1px solid var(--border-color, #eee); }
.cb-tpl-pop-chip { font-size: 12.5px; font-weight: 600; padding: 6px 13px; border-radius: 999px; cursor: pointer; color: #4b5563; background: #f4f4f6; border: 1px solid var(--border-color, #e5e7eb); }
.cb-tpl-pop-chip:hover { background: #ecebfe; }
.cb-tpl-pop-chip.active { background: #8b7cf6; color: #fff; border-color: #8b7cf6; }
.cb-tpl-pop-grid { flex: 1; overflow-y: auto; padding: 20px 22px; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 18px; align-content: start; }
.cb-tpl-pop-empty { grid-column: 1 / -1; text-align: center; color: #646B78; padding: 60px 0; font-size: 14px; }
.cb-tpl-pop-card { border: 1px solid var(--border-color, #e5e7eb); border-radius: 12px; overflow: hidden; cursor: pointer; background: #fff; transition: box-shadow .14s, border-color .14s, transform .14s; }
.cb-tpl-pop-card:hover { box-shadow: 0 8px 24px rgba(0,0,0,.1); border-color: #d8d2fb; transform: translateY(-2px); }
.cb-tpl-pop-card.current { border-color: #8b7cf6; box-shadow: 0 0 0 2px rgba(139,124,246,.25); }
.cb-tpl-pop-prev { height: 150px; display: flex; align-items: center; justify-content: center; background: #f4f4f6; }
.cb-tpl-pop-prevbox { background: #fff; border: 1px solid #e5e7eb; border-radius: 4px; display: flex; align-items: center; justify-content: center; overflow: hidden; max-width: 96%; max-height: 140px; }
.cb-tpl-pop-prevbox img { width: 100%; height: 100%; object-fit: cover; }
.cb-tpl-pop-dim { font-size: 11px; font-weight: 600; color: #646B78; }
.cb-tpl-pop-meta { padding: 10px 12px; }
.cb-tpl-pop-name { font-size: 13px; font-weight: 600; color: #1f2430; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-tpl-pop-tags { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.cb-tpl-pop-fmt { font-size: 10.5px; font-weight: 600; color: #5b4ec4; background: #f1efff; border: 1px solid #e2dcfb; border-radius: 999px; padding: 1px 8px; }
.cb-tpl-pop-badge { font-size: 10.5px; font-weight: 600; border-radius: 999px; padding: 1px 8px; }
.cb-tpl-pop-badge.on { color: #0a7d4b; background: #e9f9f0; border: 1px solid #c7eed9; }
.cb-tpl-pop-badge.cur { color: #b4640a; background: #fff4e6; border: 1px solid #ffe2bf; }
/* Render-preview button + modal (actual server/GD render of the template) */
.cb-preview-render { background: #f1efff; color: #5b4ec4; border: 1px solid #e2dcfb; font-weight: 600; }
.cb-preview-render:hover { background: #e7e3fb; }
.cb-rp-modal {
    width: auto; max-width: 92vw; max-height: 90vh; background: #fff; border-radius: 14px;
    display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.cb-rp-head { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 14px 20px; border-bottom: 1px solid var(--border-color, #e5e7eb); }
.cb-rp-head h3 { margin: 0; font-size: 16px; }
.cb-rp-body { padding: 18px 20px; overflow: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.cb-rp-img { max-width: min(640px, 86vw); max-height: 70vh; border: 1px solid var(--border-color, #e5e7eb); border-radius: 8px; background: #f4f4f6; }
.cb-rp-loading { color: #6b7280; font-size: 13px; padding: 40px 30px; }
.cb-rp-err { color: #e11d48; font-size: 13px; padding: 30px; text-align: center; }
/* Preview-product cycler (binding section) — nav/arrow/count are live;
   the old standalone Preview-section styles were removed with the dead JS. */
/* Compact preview cycler: prev/next arrows INLINE with the product card (one row). */
.cb-preview-row { display: flex; align-items: stretch; gap: 6px; }
.cb-preview-row .cb-psp { flex: 1 1 0%; min-width: 0; }   /* card grows; arrows flank it */
.cb-preview-arrow {
    flex: 0 0 auto; width: 28px; align-self: stretch; min-height: 34px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; line-height: 1; color: #4b5563;
    background: #f4f4f6; border: 1px solid var(--border-color, #e5e7eb); border-radius: 7px;
    cursor: pointer; transition: background .12s, border-color .12s, color .12s;
}
.cb-preview-arrow:hover { background: #ecebfe; border-color: #d8d2fb; color: #5b4ec4; }
/* Dynamic-text binding readout (in the right panel) */
.cb-tpl-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11.5px;
    color: #5b4ec4;
    background: #f6f5ff;
    border: 1px solid #e7e3fb;
    border-radius: 6px;
    padding: 7px 9px;
    word-break: break-word;
    line-height: 1.45;
}
/* Dynamic-text composer modal (Dotidot-style) */
.cb-dyn-hint { font-size: 12.5px; color: var(--text-muted, #6b7280); line-height: 1.7; margin-bottom: 12px; }
.cb-dyn-hint code { font-size: 11.5px; background: var(--surface-2, #f3f4f6); color: var(--text, #374151); padding: 1px 5px; border-radius: 4px; white-space: nowrap; }
.cb-dyn-ta {
    width: 100%; box-sizing: border-box; resize: vertical; min-height: 64px;
    font-size: 13px; line-height: 1.5; padding: 10px 11px;
    border: 1px solid var(--border-color, #dcdfe6); border-radius: 9px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text-strong, #1f2430);
}
.cb-dyn-ta:focus { outline: none; border-color: #8b7cf6; box-shadow: 0 0 0 3px rgba(139,124,246,.14); }
.cb-dyn-chiplabel { font-size: 11px; font-weight: 600; color: var(--text-muted, #6b7280); margin: 12px 0 6px; }
.cb-dyn-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.cb-dyn-chip {
    font-size: 12px; padding: 5px 10px; border-radius: 999px; cursor: pointer;
    background: #eef0fe; color: #5b5bd6; border: 1px solid #e1e4fb;
}
.cb-dyn-chip:hover { background: #e3e6fd; }
.cb-dyn-chip-fmt { background: #fff4e6; color: #b4640a; border-color: #ffe2bf; }
.cb-dyn-chip-fmt:hover { background: #ffe9cf; }
.cb-dyn-preview {
    font-size: 13px; color: var(--text-strong, #1f2430); background: var(--bg-subtle, #f6f7fb);
    border: 1px solid var(--border-color, #ececf1); border-radius: 9px; padding: 11px 13px; min-height: 20px; line-height: 1.5;
}
.cb-dyn-foot { display: flex; justify-content: flex-end; gap: 9px; padding: 13px 20px; border-top: 1px solid var(--border-color, #eceef3); }

.shape-btn {
    flex: 1;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius);
    transition: all var(--transition);
}

.shape-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}

/* --- Elements Section (Insert Panel) --- */
.elements-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-top: 8px;
}

.element-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius);
    font: inherit;
    font-size: 11px;
    text-align: center;
    transition: all var(--transition);
}

.element-card:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
    color: var(--accent);
}

.element-card svg { opacity: 0.7; }
.element-card:hover svg { opacity: 1; }

/* --- Insert Sub-Panel Navigation --- */
.insert-root { display: block; }
.insert-subpanel {
    display: none;
    flex-direction: column;
    height: 100%;
}

.subpanel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.subpanel-back {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border: none; background: none; cursor: pointer;
    color: var(--text-primary); border-radius: var(--radius-sm);
}
.subpanel-back:hover { background: var(--bg-hover); }

.subpanel-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }

.subpanel-content { flex: 1; overflow-y: auto; padding: 12px; }

/* --- Text Sub-Panel --- */
.text-quick-insert { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }

.text-quick-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px;
    border: 1px solid var(--border); background: var(--bg-secondary);
    border-radius: var(--radius); cursor: pointer; font: inherit; text-align: left;
    transition: all var(--transition);
}
.text-quick-row:hover { border-color: var(--accent); background: var(--bg-hover); }
.text-quick-name { font-size: 16px; color: var(--text-primary); }
.text-quick-label { font-size: 12px; color: var(--text-muted); font-family: var(--font); }

.text-compositions-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }

.text-comp-card {
    aspect-ratio: 1; min-height: 110px;
    border: 1px solid var(--border); background: var(--bg-secondary);
    border-radius: var(--radius); cursor: pointer; padding: 10px;
    display: flex; flex-direction: column; justify-content: center;
    overflow: hidden; transition: all var(--transition);
}
.text-comp-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }

.text-comp-preview { display: flex; flex-direction: column; gap: 2px; width: 100%; overflow: hidden; }
.text-comp-line { overflow: hidden; text-overflow: ellipsis; }

/* Text preset CATEGORIES (Canva-style groups) — list rows + in-panel back */
.text-cat-host { display: flex; flex-direction: column; }
.text-cat-list { display: flex; flex-direction: column; gap: 8px; }
.text-cat-row {
    display: flex; align-items: center; gap: 12px;
    padding: 8px; border: 1px solid var(--border); background: var(--bg-secondary);
    border-radius: var(--radius); cursor: pointer; font: inherit; text-align: left;
    transition: all var(--transition);
}
.text-cat-row:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.text-cat-row-thumb {
    flex: 0 0 auto; width: 56px; height: 56px;
    border-radius: 6px; background: var(--bg-tertiary, var(--bg-secondary));
    display: flex; flex-direction: column; justify-content: center;
    padding: 6px; overflow: hidden; pointer-events: none;
}
.text-cat-row-thumb .text-comp-line {
    font-size: 7px !important; line-height: 1.15 !important;
    margin-top: 1px !important; letter-spacing: 0 !important;
}
.text-cat-row-meta { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }
.text-cat-row-label { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.text-cat-row-count { font-size: 12px; color: var(--text-muted); }
.text-cat-row-chev { flex: 0 0 auto; color: var(--text-muted); display: flex; }

.text-cat-back {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 4px; margin-bottom: 10px;
    border: none; background: none; cursor: pointer; font: inherit;
    color: var(--text-primary); font-weight: 600; font-size: 14px;
    transition: color var(--transition);
}
.text-cat-back:hover { color: var(--accent); }

/* --- Button Sub-Panel --- */
.button-presets-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.button-preset-card {
    border: 1px solid var(--border); background: var(--bg-secondary);
    border-radius: var(--radius); cursor: pointer; padding: 6px 4px;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition); min-height: 36px;
}
.button-preset-card:hover { border-color: var(--accent); }

.button-preset-preview {
    padding: 5px 10px; border-radius: 6px;
    font-size: 10px; font-weight: 600; font-family: var(--font);
    text-align: center; white-space: nowrap;
    line-height: 1.3;
}

/* --- Shapes Sub-Panel --- */
.shapes-search {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border); background: var(--bg-tertiary);
    border-radius: var(--radius); margin-bottom: 12px; color: var(--text-muted);
}
.shapes-search input {
    flex: 1; border: none; background: none;
    color: var(--text-primary); font: inherit; font-size: 13px; outline: none;
}
.shapes-search input::placeholder { color: var(--text-muted); }

.shapes-basic-bar { display: flex; gap: 6px; margin-bottom: 12px; }

.shape-basic-btn {
    flex: 1; aspect-ratio: 1;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); background: var(--bg-secondary);
    cursor: pointer; border-radius: var(--radius);
    transition: all var(--transition); color: var(--text-primary);
}
.shape-basic-btn:hover { background: var(--bg-hover); border-color: var(--accent); color: var(--accent); }
/* (.shape-dropdown-* removed iter 11 — the old dropdown UI is gone; shapes now use
   the sectioned sub-panel.) */

.shape-category-header {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 10px 8px;
    border: none; background: none; cursor: pointer;
    font: inherit; font-size: 13px; color: var(--text-primary); text-align: left;
    border-radius: var(--radius-sm); transition: background var(--transition);
}
.shape-category-header:hover { background: var(--bg-hover); }

.shape-category.expanded .shape-category-header {
    background: var(--accent-subtle); border-radius: var(--radius-sm);
}

.shape-cat-icon { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; opacity: 0.8; }
.shape-cat-icon svg { width: 22px; height: 22px; }
.shape-cat-label { flex: 1; font-weight: 500; }
.shape-cat-count { font-size: 11px; color: var(--text-muted); margin-right: 4px; }
.shape-cat-chevron { transition: transform var(--transition); color: var(--text-muted); flex-shrink: 0; }
.shape-category.expanded .shape-cat-chevron { transform: rotate(90deg); }

.shapes-loading, .shapes-empty {
    padding: 24px 12px; text-align: center; color: var(--text-muted); font-size: 13px;
}

.shape-category-grid {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 4px; padding: 8px 4px 12px;
}

.shape-grid-item {
    aspect-ratio: 1;
    display: flex; align-items: center; justify-content: center;
    border: none; background: none; cursor: pointer;
    border-radius: var(--radius-sm); padding: 4px;
    transition: background var(--transition); color: var(--text-primary);
}
.shape-grid-item:hover { background: var(--bg-hover); }
.shape-grid-item svg, .shape-grid-item img { width: 100%; height: 100%; object-fit: contain; }
.shape-grid-item img { filter: brightness(0); }

/* --- Layers Panel --- */
.layers-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* (Old layer-item styles removed — see Enhanced Layers Panel section below) */

/* --- Sizes Panel --- */
.sizes-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* --- Sizes Panel --- */
.sizes-panel {
    flex-direction: column;
    height: 100%;
}
.sizes-panel.active {
    display: flex;
}

.sizes-panel-header {
    padding: 10px 14px 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sizes-panel-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.sizes-panel-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 6px;
}

.sizes-orient-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 10px 10px 4px;
}

.sizes-list-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border: none;
    background: none;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 12px;
    text-align: left;
    transition: background var(--transition);
}

.sizes-list-item:hover { background: var(--bg-hover); }
.sizes-list-item.active { background: var(--accent-subtle); }

.sizes-item-badge {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.sizes-item-badge.main { background: var(--accent-secondary); }

.sizes-list-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    cursor: pointer;
}

.sizes-item-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
}

.sizes-item-dims {
    font-size: 10px;
    color: var(--text-muted);
}

.sizes-item-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity var(--transition);
}

.sizes-list-item:hover .sizes-item-actions { opacity: 1; }

.sizes-item-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    background: none;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.sizes-item-btn:hover { background: var(--bg-tertiary); color: var(--danger); }

.sizes-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 8px 10px;
    padding: 8px 16px;
    background: var(--accent-secondary);
    color: #ffffff;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition);
    flex-shrink: 0;
}

.sizes-add-btn:hover { background: var(--accent-secondary-hover); }

/* --- Add Sizes Modal --- */
.add-sizes-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-sizes-modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 540px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.add-sizes-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.add-sizes-modal-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.add-sizes-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.add-sizes-search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    outline: none;
    margin-bottom: 12px;
}

.add-sizes-search:focus { border-color: var(--accent); }

.add-sizes-custom {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.add-sizes-custom-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.add-sizes-channels {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.add-sizes-channel-group {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    overflow: hidden;
}

.add-sizes-channel-group.collapsed .add-sizes-channel-sizes { display: none; }
.add-sizes-channel-group.collapsed .chevron { transform: rotate(-90deg); }

.add-sizes-channel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    user-select: none;
}

.add-sizes-channel-header .chevron {
    transition: transform 200ms ease;
    flex-shrink: 0;
}

.add-sizes-channel-header span { flex: 1; }

.add-sizes-channel-add-all {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    border: none;
    background: none;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.add-sizes-channel-add-all:hover { background: var(--accent-subtle); }

.add-sizes-channel-sizes {
    padding: 4px 0;
}

.add-sizes-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 24px;
    font-size: 12px;
    transition: background var(--transition);
}

.add-sizes-item:hover { background: var(--bg-hover); }

.add-sizes-item-name {
    flex: 1;
    color: var(--text-primary);
}

.add-sizes-item-dims {
    color: var(--text-muted);
    font-size: 11px;
}

.add-sizes-item-status {
    font-size: 10px;
    color: var(--success);
    font-weight: 600;
    padding: 2px 8px;
    background: rgba(34, 197, 94, 0.1);
    border-radius: 8px;
}

.add-sizes-item-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--accent);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 700;
    font-size: 14px;
    transition: all var(--transition);
}

.add-sizes-item-btn:hover {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
}

.add-sizes-item.already-added {
    opacity: 0.7;
}

.sizes-list-dims {
    color: var(--text-muted);
    font-size: 11px;
}

/* --- Canvas Area --- */
.canvas-area {
    flex: 1;
    display: flex;
    overflow: hidden;
    background: var(--bg-primary);
    position: relative;

    /* Subtle checkerboard pattern */
    background-image:
        linear-gradient(45deg, #e8e8ec 25%, transparent 25%),
        linear-gradient(-45deg, #e8e8ec 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e8e8ec 75%),
        linear-gradient(-45deg, transparent 75%, #e8e8ec 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.canvas-wrapper {
    box-shadow: var(--shadow-lg);
    transition: transform 100ms ease;
}

.canvas-wrapper canvas {
    display: block;
}

/* A TRANSPARENT ARTBOARD, shown as one. Fabric paints nothing when backgroundColor is
   'transparent', so without this the artboard would simply take the workspace's own checkerboard
   and read as "the canvas is missing" rather than "this background is transparent". The pattern
   is on the artboard element (.canvas-container is what Fabric wraps the canvas in), so it is
   clipped to the artboard bounds and the frame edge stays legible. */
/* Frame-background swatches: four common grounds on one row, so the usual answer is one click
   and the colour picker is the exception rather than the only route. */
.cb-frmbg-row { display: flex; gap: 6px; padding: 7px 12px 4px; }
.cb-frmbg-sw {
    width: 22px; height: 22px; border-radius: 5px; cursor: pointer;
    border: 1px solid rgba(0,0,0,.18); box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
}
.cb-frmbg-sw:hover { outline: 2px solid var(--accent, #5B53E8); outline-offset: 1px; }

/* "Save before leaving?" — Save / Discard / Cancel. Small, centered, and never wider than the
   sentence it asks, so the three answers read as one row rather than a form. */
.cb-leave-modal {
    background: var(--bg-elevated, #fff); border-radius: 12px; padding: 20px 22px 18px;
    max-width: 380px; box-shadow: 0 18px 44px rgba(16,24,40,.22);
}
.cb-leave-modal h3 { margin: 0 0 6px; font-size: 15px; }
.cb-leave-modal p { margin: 0 0 16px; }
.cb-leave-actions { display: flex; justify-content: flex-end; gap: 8px; }

.canvas-container.is-transparent {
    background-image:
        linear-gradient(45deg, #d9dade 25%, transparent 25%),
        linear-gradient(-45deg, #d9dade 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #d9dade 75%),
        linear-gradient(-45deg, transparent 75%, #d9dade 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-color: #fff;
}

/* --- Right Panel (Properties) --- */
.right-panel {
    width: var(--right-panel-width);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
}

.right-panel .panel-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
    padding: 20px;
}

.panel-section {
    padding: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.panel-section h3 {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.prop-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.prop-row label {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 50px;
    flex-shrink: 0;
}

.prop-row span {
    font-size: 12px;
    color: var(--text-primary);
}

.prop-input {
    flex: 1;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font: inherit;
    font-size: 12px;
    outline: none;
    min-width: 0;
}

.prop-input:focus { border-color: var(--accent); }

/* .prop-select had no style at all, so its selects (render-gate "Minimum image size", animation rows) were the raw browser
   control — same field look as .prop-input (audit 2026-11-08). */
.prop-select { flex: 1; min-width: 0; height: 28px; padding: 0 26px 0 8px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--bg-secondary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center;
    -webkit-appearance: none; appearance: none; color: var(--text-primary); font: inherit; font-size: 12px; outline: none; cursor: pointer; }
.prop-select:focus { border-color: var(--accent); }

/* Number inputs */
input[type="number"].prop-input {
    width: 70px;
    -moz-appearance: textfield;
}

input[type="number"].prop-input::-webkit-inner-spin-button,
input[type="number"].prop-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
}

/* --- Position Grid --- */
.position-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.position-grid .prop-row {
    margin-bottom: 0;
}

.position-grid label {
    min-width: 16px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 11px;
}

/* --- Layer Controls --- */
.layer-controls {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.layer-control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.layer-control-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.layer-control-btn.active { background: var(--accent-subtle); color: var(--accent); border-color: var(--accent); }

/* --- Text Formatting Bar --- */
.text-format-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

.format-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    transition: all var(--transition);
}

.format-btn:hover { background: var(--bg-hover); }
.format-btn.active { background: var(--accent-subtle); color: var(--accent); border-color: var(--accent); }

/* --- Inline Property Rows (side-by-side columns) --- */
.prop-row-inline {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.prop-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.prop-col label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.prop-col .prop-input {
    width: 100%;
}

/* --- Font Selector Button --- */
.font-selector-row {
    flex-direction: column;
    align-items: stretch;
}

.font-selector-wrap {
    flex: 1;
}

.font-selector-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-primary);
    font-size: 13px;
    transition: border-color var(--transition);
}

.font-selector-btn:hover { border-color: var(--text-muted); }
.font-selector-btn:focus { border-color: var(--accent); outline: none; }

.font-selector-preview {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Font Picker Dropdown --- */
.font-picker-dropdown {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 10002;
    max-height: 380px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.font-picker-search-row {
    display: flex;
    gap: 4px;
    padding: 8px;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.font-picker-search {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font: inherit;
    font-size: 12px;
    outline: none;
}

.font-picker-search:focus { border-color: var(--accent); }

.font-picker-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition);
}

.font-picker-upload-btn:hover {
    background: var(--accent-subtle);
    color: var(--accent);
    border-color: var(--accent);
}

.font-picker-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px;
}

.font-picker-category {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 8px 10px 4px;
}

.font-picker-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 6px 10px;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-primary);
    font-size: 13px;
    text-align: left;
    transition: background var(--transition);
}

.font-picker-item:hover {
    background: var(--bg-tertiary);
}

.font-picker-item.active {
    background: var(--accent-subtle);
    color: var(--accent);
}

.font-picker-item-preview {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Text Style Toggles (B I U S) --- */
.text-style-toggles {
    display: flex;
    gap: 4px;
}

.style-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 13px;
    transition: all var(--transition);
}

.style-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }
.style-toggle.active { background: var(--accent-subtle); color: var(--accent); border-color: var(--accent); }

/* --- Color Input with Hex --- */
.color-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.color-input-wrap input[type="color"] {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px;
    cursor: pointer;
    background: none;
}

.color-hex {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: monospace;
}

/* --- Range Value Display --- */
.range-val {
    font-size: 11px;
    color: var(--text-muted);
    min-width: 24px;
    text-align: right;
}

/* --- Effect Toggle Rows --- */
/* One-tap duotone look presets (gradient swatches above the custom color pickers). */
.cb-duotone-presets { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 9px; }
.cb-duotone-preset {
    flex: 1 1 0; min-width: 50px; height: 30px; border-radius: 6px; cursor: pointer;
    border: 1.5px solid transparent; position: relative; overflow: hidden; padding: 0;
}
.cb-duotone-preset:hover { border-color: var(--text-muted, #9ca3af); }
.cb-duotone-preset.is-on { border-color: #4f46e5; box-shadow: 0 0 0 1px #4f46e5; }
.cb-duotone-preset span {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: 9.5px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .65);
    letter-spacing: .2px;
}

.effect-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.effect-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.effect-toggle {
    padding: 3px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    cursor: pointer;
    background: var(--bg-secondary);
    color: var(--text-muted);
    transition: all var(--transition);
}

.effect-toggle:hover { border-color: var(--text-muted); }
.effect-toggle.active {
    background: var(--accent-subtle);
    color: var(--accent);
    border-color: var(--accent);
}

/* --- Collapsible Effect Settings --- */
.effect-settings {
    padding: 0 0 8px 0;
    transition: max-height 200ms ease, opacity 200ms ease;
    max-height: 300px;
    opacity: 1;
    overflow: hidden;
}

.effect-settings.collapsed {
    max-height: 0;
    opacity: 0;
    padding: 0;
    margin: 0;
    pointer-events: none;
}

/* Quiet caveat shown inside an effect's settings (echo/lift): these effects
   render in the editor preview but are not yet re-applied by the export
   render-service, so warn the user before they rely on them. Remove once the
   render-service supports them. Muted, with a subtle left rule — not an alarm. */
.effect-render-note {
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-muted, #6b7280);
    margin: 0 0 8px 0;
    padding-left: 8px;
    border-left: 2px solid var(--border, #e5e7eb);
}

/* Range inputs in properties */
.prop-row input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
}

.prop-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

.prop-row input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* ============================================
   AI Panel Styles
   ============================================ */

.ai-subtabs {
    display: flex;
    gap: 2px;
    margin-bottom: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    padding: 2px;
}

.ai-subtab {
    flex: 1;
    padding: 6px 4px;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 11px;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
}

.ai-subtab:hover { color: var(--text-secondary); }
.ai-subtab.active { background: var(--bg-secondary); color: var(--text-primary); box-shadow: 0 1px 2px rgba(0,0,0,0.06); }

.ai-subtab-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ai-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-top: 6px;
}

.ai-textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    resize: vertical;
    outline: none;
    min-height: 72px;
}

.ai-textarea:focus { border-color: var(--accent); }
.ai-textarea::placeholder { color: var(--text-muted); }

.ai-select {
    width: 100%;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font: inherit;
    font-size: 12px;
    outline: none;
}

.ai-select:focus { border-color: var(--accent); }

/* --- Brand-kit row in the AI panel ---
 * Sits at the top of both Generate and Edit subtabs. Hint line stays
 * empty (zero height) when no kit is picked so the layout doesn't jump
 * for the default case. Hint becomes visible muted text when a kit is
 * active so the user knows their prompt is being augmented. */
.ai-brand-kit-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--border-subtle);
}
.ai-brand-kit-hint {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.35;
    min-height: 0;
}
.ai-brand-kit-hint--active {
    color: var(--accent);
    font-weight: 500;
}

/* Brand-kit asset gallery — appears below the dropdown when a kit is
 * selected. Shows logos + image assets as 64×64 clickable tiles. */
.ai-brand-assets {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ai-brand-assets-label {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.3;
}
.ai-brand-assets-empty {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
    padding: 6px 0;
}
.ai-brand-assets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 6px;
}
.ai-brand-tile {
    position: relative;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    cursor: pointer;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    transition: border-color var(--transition), transform var(--transition);
    display: flex;
    flex-direction: column;
}
.ai-brand-tile:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}
.ai-brand-tile img {
    flex: 1;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    min-height: 0;
}
.ai-brand-tile-label {
    font-size: 9px;
    color: var(--text-muted);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-top: 2px;
}
.ai-brand-tile.used {
    opacity: 0.55;
    cursor: default;
    border-color: var(--success);
}
.ai-brand-tile.used::after {
    content: '✓';
    position: absolute;
    top: 2px;
    right: 4px;
    color: var(--success);
    font-size: 12px;
    font-weight: 700;
}

/* LOGO badge + toggle on each reference thumbnail (AI Edit subtab) */
.ai-ref-thumb.is-logo {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-subtle);
}
.ai-ref-logo-badge {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: var(--accent);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 2px 5px;
    border-radius: 3px;
    pointer-events: none;
    z-index: 2;
}
.ai-ref-logo-toggle {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 2;
    transition: background var(--transition);
}
.ai-ref-logo-toggle:hover { background: rgba(0, 0, 0, 0.75); }
.ai-ref-logo-toggle.active { background: var(--accent); }
.ai-ref-logo-toggle.active:hover { background: var(--accent-hover); }

/* Style presets grid */
.ai-styles-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.ai-style-btn {
    padding: 6px 2px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 10px;
    text-align: center;
    transition: all var(--transition);
}

.ai-style-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.ai-style-btn.active { border-color: var(--accent); background: var(--accent-subtle); color: var(--accent); }

/* Generate button */
.ai-generate-btn {
    margin-top: 10px;
}

.ai-generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.spinner-sm {
    width: 14px;
    height: 14px;
    border-width: 2px;
    display: inline-block;
    vertical-align: middle;
}

/* Reference images */
.ai-ref-area {
    display: flex;
    gap: 6px;
}

.ai-ref-upload-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 6px;
    border: 1px dashed var(--border);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius);
    font: inherit;
    font-size: 10px;
    transition: all var(--transition);
}

.ai-ref-upload-btn:hover { border-color: var(--accent); color: var(--accent); }

.ai-ref-thumbs {
    /* Stack: thumbs row (flex inside) + optional mask panel below. The
       inner .ai-ref-thumbs-row owns the horizontal flex layout now. */
    display: flex;
    flex-direction: column;
    margin-top: 6px;
}

.ai-ref-thumb {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}
/* When a mask is set, give the thumb a colored ring so the user can spot
   masked references at a glance. */
.ai-ref-thumb.has-mask {
    border-color: #ef4444;
    box-shadow: 0 0 0 1px #ef4444;
}

.ai-ref-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-ref-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 10px;
    line-height: 1;
}
/* Wrapper for the row of thumb cards (so we can stack the mask panel below) */
.ai-ref-thumbs-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
/* Mask paintbrush button — bottom-left corner of the thumb. Bumped to 22×22
   so it's actually visible on the small 56px thumb. Indigo highlight on
   hover so it reads as an action, not decoration. */
.ai-ref-mask-btn {
    position: absolute;
    bottom: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.92);
    color: #fff;
    border: 1.5px solid #fff;
    border-radius: 5px;
    cursor: pointer;
    padding: 0;
    transition: all 0.12s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.ai-ref-mask-btn:hover {
    background: #5B53E8;
    transform: scale(1.08);
}
.ai-ref-mask-btn.has-mask { background: #ef4444; }
.ai-ref-mask-btn.has-mask:hover { background: #dc2626; }
/* Tiny "✓ mask" badge — bottom-right pill. Click to clear the mask without
   removing the ref. */
.ai-ref-mask-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 1px 4px;
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 9px;
    font-weight: 600;
    line-height: 1;
    text-transform: uppercase;
}
.ai-ref-mask-badge:hover { background: #dc2626; }

/* Full-width mask action panel — appears below the thumbs row whenever
   refs exist. Makes the "draw a mask" workflow obviously discoverable
   instead of buried on a 22×22 corner button.

   Stacks vertically (info → actions) so the panel reads cleanly inside
   the narrow ~320px AI sidebar. A horizontal flex layout was crushing
   "Mask set on image #1" into a 3-line wrap and the hint into a sliver. */
.ai-ref-mask-panel {
    margin-top: 8px;
    padding: 10px 12px;
    background: linear-gradient(90deg, #f5f5ff 0%, #fafafd 100%);
    border: 1px dashed #c7c9f5;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ai-ref-mask-panel.active {
    background: linear-gradient(90deg, #fef2f2 0%, #fff5f5 100%);
    border-color: #ef4444;
    border-style: solid;
}
.ai-ref-mask-panel-info { min-width: 0; }
.ai-ref-mask-panel-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 4px;
    line-height: 1.3;
    /* Keep the title on one line when there's room; ellipsis if not. */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ai-ref-mask-panel.active .ai-ref-mask-panel-title { color: #b91c1c; }
.ai-ref-mask-panel-hint {
    font-size: 11px;
    color: #646B78;
    line-height: 1.45;
}
.ai-ref-mask-panel-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}
.ai-ref-mask-panel-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    /* Primary action takes most of the row; secondary (Clear) sits beside. */
}
.ai-ref-mask-panel-actions .btn-primary { flex: 1; justify-content: center; }
.ai-ref-mask-panel-actions .btn-ghost {
    background: transparent;
    border: 1px solid transparent;
    color: #646B78;
    padding: 6px 10px;
}
.ai-ref-mask-panel-actions .btn-ghost:hover { color: #ef4444; background: rgba(239, 68, 68, 0.08); }

/* ============================================================================
   Mask Painter Modal
   ============================================================================ */
.mask-painter-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.mask-painter-modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.4);
    width: min(900px, 96vw);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.mask-painter-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid #e6e6ec;
    background: #fafafd;
}
.mask-painter-title {
    flex: 1;
    font-size: 14px;
    color: #1a1a2e;
}
.mask-painter-title strong { font-weight: 600; }
.mask-painter-hint {
    color: #646B78;
    font-weight: 400;
    margin-left: 6px;
}

.mask-painter-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid #e6e6ec;
    flex-wrap: wrap;
}
.mask-painter-tool {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #fff;
    border: 1px solid #e6e6ec;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    color: #1a1a2e;
    transition: all 0.12s;
}
.mask-painter-tool:hover { border-color: #5B53E8; color: #5B53E8; }
.mask-painter-tool.active {
    background: #5B53E8;
    border-color: #5B53E8;
    color: #fff;
}
.mask-painter-size {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 6px;
    border-left: 1px solid #e6e6ec;
    margin-left: 4px;
}
.mask-painter-size label {
    font-size: 11px;
    color: #646B78;
    margin-right: 4px;
}
.mask-painter-size input[type="range"] {
    width: 120px;
    accent-color: #5B53E8;
}
.mask-painter-size-label {
    font-size: 11px;
    color: #1a1a2e;
    min-width: 36px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.mask-painter-stage {
    flex: 1;
    overflow: auto;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: repeating-conic-gradient(#f0f1f5 0% 25%, #fff 0% 50%) 50% / 16px 16px;
    min-height: 320px;
}
.mask-painter-canvas {
    max-width: 100%;
    max-height: calc(92vh - 220px);
    cursor: crosshair;
    touch-action: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    border-radius: 4px;
    display: block;
}

.mask-painter-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid #e6e6ec;
    background: #fafafd;
}
.mask-painter-footer-hint {
    flex: 1;
    font-size: 11px;
    color: #646B78;
}
.mask-painter-footer .btn {
    padding: 8px 16px;
    font-size: 13px;
}

.ai-ref-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 9px;
    text-align: center;
    padding: 1px 0;
}

/* AI Tools */
.ai-tools-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.ai-tool-btn {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
}

.ai-tool-btn div {
    display: flex;
    flex-direction: column;
}

.ai-tool-btn strong { font-size: 12px; font-weight: 500; }
.ai-tool-btn small { font-size: 10px; color: var(--text-muted); }

.ai-cost-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    color: #16a34a;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 4px;
    padding: 1px 5px;
    margin-left: 6px;
    vertical-align: middle;
    line-height: 1.4;
}

.ai-product-scene {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle);
}

/* AI Results */
.ai-results {
    margin-top: 10px;
    border-top: 1px solid var(--border-subtle);
    padding-top: 8px;
}

.ai-results-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 8px;
}
.ai-results-tab {
    flex: 1;
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
}
.ai-results-tab:hover { color: var(--text-primary); }
.ai-results-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.ai-results-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 8px;
}

.ai-results-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

/* New-tab variant: single-column full-width cards instead of the
 * 2-column icon grid. Each card stacks an image + a labelled button
 * row beneath, so the user can read each action without hovering. */
.ai-results-grid--new {
    grid-template-columns: 1fr;
    gap: 12px;
}

/* (ai-result-thumb styles consolidated in section below) */

/* --- Full-width labelled card (used in the New-results view) --- */
.ai-result-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.ai-result-card-img {
    position: relative;
    background: var(--bg-tertiary);
    cursor: zoom-in;
    line-height: 0;
}
.ai-result-card-img img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 360px;            /* clamp very tall images so the button row stays visible */
    object-fit: contain;
}
.ai-result-card-img .ai-result-model-tag {
    /* Inherits position/styling from the existing .ai-result-model-tag
     * rule below (bottom-left badge). Repeated here only so an upgrade
     * to the existing rule won't accidentally hide it on the new card. */
    position: absolute;
    left: 8px;
    bottom: 8px;
}

/* 2×2 button grid under the image. Each button shows icon + label. */
.ai-result-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 8px;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
}
.ai-result-card-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-primary);
    font: inherit;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.ai-result-card-btn:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}
.ai-result-card-btn svg { flex-shrink: 0; opacity: 0.85; }
.ai-result-card-btn:hover svg { opacity: 1; }

/* "Edit with AI" gets the same muted-red treatment as the right-panel
 * + left-panel Edit-with-AI buttons — keeps the AI-edit affordance
 * visually consistent across the editor. */
.ai-result-card-btn--accent {
    background: #b91c1c;
    color: #fff;
    border-color: #a01919;
    font-weight: 600;
}
.ai-result-card-btn--accent:hover {
    background: #991b1b;
    border-color: #7f1717;
    color: #fff;
}
.ai-result-card-btn--accent svg { opacity: 1; }

/* AI Status messages */
.ai-status {
    padding: 8px 10px;
    border-radius: var(--radius);
    font-size: 12px;
    margin-bottom: 8px;
}

.ai-status-info { background: var(--accent-subtle); color: var(--accent); }
.ai-status-success { background: rgba(34, 197, 94, 0.1); color: var(--success); }
.ai-status-error { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* ============================================
   Generator View — Creatopy-style multi-size canvas
   ============================================ */
.generator-view {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    /* workspace | bottom dock (template mode; empty row otherwise) | zoom bar */
    grid-template-rows: minmax(0, 1fr) auto auto;
    background: #f5f5f7;
    overflow: hidden;
}

/* Bottom zoom bar (Creatopy-style) */
.gen-zoom-bar {
    grid-row: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    min-height: 36px;
    z-index: 10;
}

.gen-zoom-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
/* "Check text contrast" — the WCAG AA/AAA check of the final render (render-contrast.js). */
.gen-contrast-btn { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 7px;
    border: 1px solid var(--border, #e2e4ea); background: var(--surface, #fff); color: var(--text-secondary, #4b5060);
    font: 500 12px/1 inherit; cursor: pointer; white-space: nowrap; }
.gen-contrast-btn:hover { border-color: var(--accent, #5B53E8); color: var(--accent, #5B53E8); }
.gen-contrast-btn:focus-visible { outline: 2px solid var(--accent, #5B53E8); outline-offset: 2px; }
.gen-contrast-tag { font-size: 10.5px; font-weight: 700; color: var(--accent, #5B53E8); background: #f1efff; border-radius: 5px; padding: 2px 5px; }
/* Live result of the 10-second background check (cbShowContrastStatus). */
.gen-contrast-tag[data-kind="bad"] { color: #b42318; background: #fdecea; }
.gen-contrast-tag[data-kind="warn"] { color: #93370d; background: #fef6e7; }
.gen-contrast-tag[data-kind="ok"] { color: #046c4e; background: #e7f8ef; }
.gen-contrast-btn:has(.gen-contrast-tag[data-kind="bad"]) { border-color: #f5b5ae; }

.gen-zoom-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
}

.gen-zoom-controls {
    display: flex;
    align-items: center;
    gap: 2px;
}

.gen-zoom-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
    transition: background var(--transition);
}

.gen-zoom-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.gen-zoom-percent {
    padding: 2px 8px;
    border: none;
    background: none;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    min-width: 44px;
    text-align: center;
}

.gen-zoom-percent:hover {
    background: var(--bg-tertiary);
}

/* Timeline toggle in bottom bar */
.gen-timeline-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    background: none;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    margin-left: 8px;
}
.gen-timeline-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--text-muted);
}
.gen-timeline-toggle.active {
    background: rgba(99,102,241,0.1);
    color: var(--accent);
    border-color: var(--accent);
}

/* Zoom dropdown menu (Creatopy-style) */
.zoom-menu {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 10001;
    min-width: 180px;
    padding: 4px;
    max-height: 400px;
    overflow-y: auto;
}

.zoom-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 7px 12px;
    border: none;
    background: none;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-primary);
    font-size: 13px;
    transition: background var(--transition);
}

.zoom-menu-item:hover {
    background: var(--bg-tertiary);
}

.zoom-menu-label {
    font-weight: 400;
}

.zoom-menu-shortcut {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

.zoom-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 8px;
}

/* Scrollable workspace — big canvas, scrolls both ways, never constrains artboards */
.gen-workspace {
    grid-row: 1;
    overflow: auto;
    min-height: 0;
    min-width: 0;
    position: relative;
}

/* Drop-active state — applied while the user is dragging an image file
 * over the canvas workspace. The inset ring + accent tint gives a clear
 * visual landing target without introducing a separate overlay element
 * (which would intercept pointer events and complicate the existing
 * pan/scroll wiring). */
.gen-workspace-drop-active {
    outline: 3px dashed var(--accent);
    outline-offset: -10px;
    background: var(--accent-subtle);
}
.gen-workspace-drop-active::after {
    content: 'Drop image to add as layer';
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    pointer-events: none;
    z-index: 50;
}

/* Inner content wrapper — takes natural width, workspace scrolls around it */
.gen-ws-content {
    display: flex;
    flex-direction: column;
    min-width: max-content;
    padding: max(40px, 40vh) max(48px, 50vw) max(80px, 40vh);
}

/* Section label ("MAIN LAYOUTS", "OTHER LAYOUTS") */
.gen-section-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: rgba(0,0,0,0.25);
    padding: 0 4px 12px;
    display: block;
}

/* ===== Shared columns row — used in both main and other sections ===== */
.gen-columns-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 48px;
    align-items: flex-end;
    min-width: min-content;
}

/* ===== Main layouts section — dotted background with label at top ===== */
.gen-main-section {
    background-image: radial-gradient(circle, rgba(0,0,0,0.08) 1px, transparent 1px);
    background-size: 16px 16px;
    border-radius: 12px;
    padding: 16px 32px 20px;
    margin-bottom: 0;
}

/* Each main column: just the artboard */
.gen-main-column {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

/* ===== Divider row — horizontal line with arrow buttons centered under main artboards ===== */
.gen-divider-row {
    position: relative;
    height: 36px;
}

.gen-divider-line {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 2px;
    background: var(--border);
}

/* Orange down-arrow button — absolutely positioned, centered under main artboard via JS */
.gen-adapt-arrow-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--bg-primary);
    background: var(--accent-secondary);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 8px rgba(232,80,47,0.3);
}
.gen-adapt-arrow-btn:hover {
    background: var(--accent-secondary-hover);
}

/* ===== Other layouts section ===== */
.gen-other-section {
    padding: 16px 32px 20px;
}

/* Other section columns start from top (same Y) */
.gen-other-section > .gen-columns-row {
    align-items: flex-start;
}

/* Each other column: stacks children vertically, width synced via JS */
.gen-other-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ===== Single artboard (shared base) ===== */
.gen-artboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: opacity 0.2s ease;
}

/* When a size is focused, fade non-active artboards */
.generator-view.has-focus .gen-artboard:not(.gen-artboard-active) {
    opacity: 0.35;
    pointer-events: auto;
}
.generator-view.has-focus .gen-artboard:not(.gen-artboard-active):hover {
    opacity: 0.65;
}

/* "◆ Main square/vertical/horizontal" tag — Creatopy diamond style */
.gen-main-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    padding: 0 0 4px 0;
}

.gen-diamond {
    color: var(--accent-secondary);
    font-size: 10px;
}

/* Canvas wrapper */
.gen-artboard-canvas-wrap {
    position: relative;
    border-radius: 4px;
    overflow: visible;
    box-shadow: 0 1px 6px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
    background: #fff;
    transition: box-shadow var(--transition);
}

.gen-artboard:hover .gen-artboard-canvas-wrap {
    box-shadow: 0 2px 12px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.06);
}

.gen-artboard-active .gen-artboard-canvas-wrap {
    box-shadow: 0 0 0 2px var(--accent), 0 2px 12px rgba(99,102,241,0.2);
}

/* Orange circle adapt button — floats to the right of main artboard */
.gen-adapt-circle {
    position: absolute;
    right: -20px;
    top: 50%;
    transform: translateX(100%) translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--accent-secondary);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
    box-shadow: 0 2px 8px rgba(232,80,47,0.3);
    z-index: 5;
}
.gen-adapt-circle:hover {
    background: var(--accent-secondary-hover);
    transform: translateX(100%) translateY(-50%) scale(1.1);
}

/* The actual canvas/preview inside the wrapper */
.gen-artboard-canvas {
    display: block;
    overflow: hidden;
    border-radius: 4px;
}

.gen-artboard-canvas img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Label below artboard */
.gen-artboard-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 2px 0;
}

.gen-artboard-name {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* Action buttons for non-main artboards (... menu + adapt star) */
.gen-artboard-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
}
.gen-artboard:hover .gen-artboard-actions {
    opacity: 1;
}

.gen-artboard-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
}
.gen-artboard-action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Active artboard info bar */
.gen-artboard-infobar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 4px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
/* Editable main info bar — click anywhere to open the size editor */
.gen-artboard-infobar-editable { cursor: pointer; transition: border-color 0.12s, background 0.12s; }
.gen-artboard-infobar-editable:hover { border-color: var(--accent); background: var(--accent-subtle); }
.gen-infobar-edit { display: inline-flex; align-items: center; color: var(--text-muted); margin-left: 2px; }
.gen-artboard-infobar-editable:hover .gen-infobar-edit { color: var(--accent); }

/* Top-bar size indicator — clickable, opens the canvas size picker */
.toolbar-size-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 8px 5px 10px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary, #4b5563);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.toolbar-size-indicator:hover {
    background: var(--bg-tertiary, #f3f4f6);
    border-color: var(--border, #e5e7eb);
    color: var(--text-primary, #111827);
}
.toolbar-size-caret { display: inline-flex; color: var(--text-muted, #9ca3af); }
.toolbar-size-indicator:hover .toolbar-size-caret { color: var(--accent, #5B53E8); }

/* ── Canvas size picker popover (Popular / All sizes / Custom) ──────── */
.size-picker-pop {
    position: fixed;
    z-index: 9500;
    width: 440px;
    max-width: calc(100vw - 16px);
    max-height: min(72vh, 620px);
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary, #fff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 14px;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.26);
    overflow: hidden;
}
.size-picker-head {
    display: flex; align-items: baseline; justify-content: space-between;
    padding: 14px 16px 10px;
}
.size-picker-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.size-picker-current { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.size-picker-tabs {
    display: flex;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-subtle, #eef0f4);
}
.size-picker-tab {
    appearance: none; border: none; background: none;
    padding: 8px 2px 10px;
    margin-right: 18px;
    font-size: 13px; font-weight: 600;
    color: var(--text-muted, #9ca3af);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-family: inherit;
    transition: color 0.12s, border-color 0.12s;
}
.size-picker-tab:hover { color: var(--text-secondary); }
.size-picker-tab.is-active { color: var(--accent, #5B53E8); border-bottom-color: var(--accent, #5B53E8); }

.size-picker-body { padding: 12px 16px 16px; overflow-y: auto; }

.size-picker-group-title {
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--text-muted, #9ca3af);
    margin: 16px 0 8px;
}
.size-picker-group-title:first-child { margin-top: 2px; }

.size-picker-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.size-picker-card {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    text-align: left;
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
}
.size-picker-card:hover { border-color: var(--accent, #5B53E8); box-shadow: 0 2px 8px rgba(99, 102, 241, 0.12); }
.size-picker-card.is-active { border-color: var(--accent, #5B53E8); background: var(--accent-subtle, #eef2ff); }
.size-picker-thumb {
    flex: 0 0 44px; width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
}
.size-picker-thumb-box {
    background: linear-gradient(135deg, #c7cbf5, #5B53E8);
    border-radius: 3px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.size-picker-card.is-active .size-picker-thumb-box { background: linear-gradient(135deg, #8b8ff7, #4f46e5); }
.size-picker-card-meta { min-width: 0; }
.size-picker-card-label {
    font-size: 12.5px; font-weight: 600; color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.size-picker-card-dims { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Custom tab */
.size-picker-custom { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.size-picker-custom-row { display: flex; align-items: flex-end; gap: 10px; }
.size-picker-field { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.size-picker-field label { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.size-picker-input {
    width: 100%; padding: 9px 10px;
    font-size: 14px; font-family: inherit;
    border: 1px solid var(--border, #e2e5ee); border-radius: 9px;
    background: var(--bg-primary, #fff); color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.size-picker-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }
.size-picker-swap {
    flex: 0 0 auto; width: 34px; height: 38px; margin-bottom: 1px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-muted); background: var(--bg-tertiary, #f3f4f6);
    border: 1px solid var(--border, #e5e7eb); border-radius: 9px; cursor: pointer;
    transition: color 0.12s, border-color 0.12s;
}
.size-picker-swap:hover { color: var(--accent); border-color: var(--accent); }
.size-picker-ratios { display: flex; flex-wrap: wrap; gap: 6px; }
.size-picker-ratio {
    padding: 6px 12px; font-size: 12px; font-weight: 600;
    color: var(--text-secondary); background: var(--bg-tertiary, #f3f4f6);
    border: 1px solid transparent; border-radius: 999px; cursor: pointer;
    font-family: inherit;
    transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.size-picker-ratio:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-subtle); }
.size-picker-apply { width: 100%; justify-content: center; margin-top: 2px; }

/* Danger item in context menu */
.adapt-menu-danger {
    color: #ef4444 !important;
}
.adapt-menu-danger:hover {
    background: rgba(239,68,68,0.1) !important;
}

/* Adapt context menu */
.adapt-menu {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    min-width: 220px;
    padding: 4px;
}

.adapt-menu-title {
    padding: 8px 12px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.adapt-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    font-size: 13px;
    border: none;
    background: none;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-primary);
    transition: background var(--transition);
}

.adapt-menu-item:hover {
    background: var(--accent-subtle);
    color: var(--accent);
}

/* --- AI per-variant model selectors --- */
.ai-variant-models {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
    margin-bottom: 8px;
}

.ai-variant-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-variant-num {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.ai-variant-model-select {
    flex: 1;
    font-size: 12px;
}

/* Variant block — model + its options grouped, visually distinct card */
.ai-variant-block {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: 10px 10px 8px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    position: relative;
}
.ai-variant-block::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
}

/* Model options container inside variant block */
.ai-model-options {
    /* Stack option groups VERTICALLY (one per line) — was a flex-wrap row,
       which made labels read on the side and squeezed segmented buttons.
       Stacked layout matches the AI Studio per-model panel and gives each
       control its full width. */
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}
.ai-model-options:empty {
    display: none;
}

.ai-option-group {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 8px 10px;
    border: 1px solid var(--border);
}

/* Segmented buttons — matches the studio's per-model option pattern. Used
   for short-list options like quality (low/medium/high) or thinking_level
   (off/min/high) where a dropdown is overkill. */
.ai-option-segmented {
    display: flex;
    gap: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2px;
}
.ai-option-seg-btn {
    flex: 1;
    padding: 6px 10px;
    background: transparent;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: background 0.12s, color 0.12s;
    text-transform: capitalize;
}
.ai-option-seg-btn:hover { color: var(--text-primary); }
.ai-option-seg-btn.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 1px 3px rgba(99, 102, 241, 0.3);
}

/* ============================================================================
   Edit-with-AI before/after comparison modal — pops after a successful edit.
   ============================================================================ */
.ai-edit-compare-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.ai-edit-compare-modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
    width: min(960px, 96vw);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.ai-edit-compare-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}
.ai-edit-compare-header h3 {
    flex: 1;
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.ai-edit-compare-row {
    flex: 1;
    overflow: auto;
    padding: 18px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    background: repeating-conic-gradient(#f0f1f5 0% 25%, #fff 0% 50%) 50% / 16px 16px;
}
.ai-edit-compare-col {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}
/* Original / Edited label above each compare image. Previously this was a
   tiny 11px muted-color caption that visually disappeared against the
   checkerboard background — users couldn't tell at a glance which side was
   the original. Now a high-contrast pill with a colored border + a leading
   dot so left/right read instantly. The :nth-of-type selectors target the
   two sibling labels — first column is "Original" (neutral), second is
   "Edited" (accent green). */
.ai-edit-compare-label {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    align-self: flex-start;
    padding: 6px 12px;
    border-radius: 999px;
    background: #fff;
    color: var(--text-primary);
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.ai-edit-compare-label::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    flex-shrink: 0;
}
/* Second column ("Edited") gets the accent treatment so the user's eye
   immediately tracks to the new result. Indigo to match the app's primary
   accent + a brighter dot. */
.ai-edit-compare-col:nth-of-type(2) .ai-edit-compare-label {
    color: #4f46e5;
    border-color: #c7d2fe;
    background: #eef2ff;
}
.ai-edit-compare-col:nth-of-type(2) .ai-edit-compare-label::before {
    background: #5B53E8;
}
.ai-edit-compare-col img {
    width: 100%;
    max-height: 60vh;
    object-fit: contain;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}
/* Carousel arrows for variant navigation — only rendered when >1 result. */
.ai-edit-compare-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.95);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: background 0.12s, color 0.12s;
}
.ai-edit-compare-arrow:hover { background: var(--accent); color: #fff; }
.ai-edit-compare-prev { left: -8px; }
.ai-edit-compare-next { right: -8px; }

.ai-edit-compare-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}
.ai-edit-compare-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 500;
}
.ai-edit-compare-actions .btn-primary {
    flex: 1;
    min-width: 180px;
    justify-content: center;
}

/* Single-column layout for narrow viewports — stack original above edited. */
@media (max-width: 720px) {
    .ai-edit-compare-row {
        grid-template-columns: 1fr;
    }
}

.ai-option-label {
    display: block;
    font-size: 9px;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

/* Custom-dim row (W × H px) revealed when "Custom dimensions…" is selected
   in the canvas editor's GPT Image 2 image_size dropdown. */
.ai-option-custom-dims {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed var(--border);
}
.ai-option-num-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
}
.ai-option-num-x {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
}
.ai-option-num-suffix {
    font-size: 10px;
    color: var(--text-muted);
    margin-left: 2px;
}
.ai-option-num-input {
    width: 56px;
    padding: 3px 5px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 11px;
    background: var(--bg);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.ai-option-num-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.18);
}

.ai-model-option-select {
    width: 100%;
    font-size: 11px;
    padding: 4px 6px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

/* AI result thumbnails */
.ai-result-thumb {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
}

.ai-result-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius);
}

/* Hover overlay with action buttons */
.ai-result-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(0,0,0,0.3);
    opacity: 0;
    transition: opacity var(--transition);
    border-radius: var(--radius);
}

.ai-result-thumb:hover .ai-result-overlay {
    opacity: 1;
}

.ai-result-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.9);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.ai-result-action:hover {
    background: #fff;
    transform: scale(1.1);
}

.ai-result-model-tag {
    position: absolute;
    bottom: 4px;
    left: 4px;
    font-size: 9px;
    font-weight: 600;
    background: rgba(0,0,0,0.6);
    color: #fff;
    padding: 1px 6px;
    border-radius: 3px;
    pointer-events: none;
    white-space: nowrap;
}

/* Full-screen image preview with interactive zoom */
.ai-preview-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20000;
    background: rgba(0,0,0,0.85);
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ai-preview-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 10px 16px;
    flex-shrink: 0;
}

.ai-preview-zoom-label {
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.7);
}



.ai-preview-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: grab;
}

.ai-preview-img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    user-select: none;
    transition: transform 0.05s ease-out;
}

/* ============================================
   Export Dialog — Creatopy-style right panel overlay
   ============================================ */
.export-dialog {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 24px rgba(0,0,0,0.12);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.export-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.export-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}



.export-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.export-field {
    margin-bottom: 14px;
}

.export-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 5px;
}

.export-select {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    outline: none;
}

.export-select:focus { border-color: var(--accent); }

.export-settings-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 12px 0 8px;
    border-top: 1px solid var(--border-subtle);
    margin-top: 4px;
}

.export-type-toggle {
    display: flex;
    gap: 4px;
}

.export-type-btn {
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition);
}

.export-type-btn.active {
    background: var(--accent-subtle);
    color: var(--accent);
    border-color: var(--accent);
}

.export-sizes-list {
    margin-top: 8px;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
}

.export-size-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    font-size: 12px;
    color: var(--text-primary);
    cursor: pointer;
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition);
}

.export-size-item:last-child { border-bottom: none; }
.export-size-item:hover { background: var(--bg-tertiary); }

.export-size-item.export-size-all {
    font-weight: 600;
    background: var(--bg-tertiary);
}

.export-size-item input[type="checkbox"] {
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.export-size-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.export-size-dims {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.export-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.export-download-btn {
    width: 100%;
    padding: 10px 20px;
    background: var(--accent-secondary);
    color: #ffffff;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition);
}

.export-download-btn:hover { background: var(--accent-secondary-hover); }
.export-download-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ============================================
   Animation Timeline (Redesigned)
   ============================================ */

/* --- Header: Playback + Scrubber + Settings --- */
.anim-header {
    border-bottom: 1px solid var(--border);
}
.anim-playback-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px 6px;
}
.anim-play-btn {
    width: 34px; height: 34px;
    background: var(--accent); color: #fff; border-radius: 50%;
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--transition);
    flex-shrink: 0;
}
.anim-play-btn:hover { background: #5558e6; }
.anim-ctrl-btn {
    width: 28px; height: 28px;
    border: none; background: none; color: var(--text-secondary);
    cursor: pointer; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.anim-ctrl-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.anim-time-display {
    font-size: 11px; color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    min-width: 70px;
    white-space: nowrap;
}
.anim-speed-sel {
    font-size: 11px; padding: 2px 4px;
    border: 1px solid var(--border); border-radius: 4px;
    background: var(--bg-secondary); color: var(--text-primary);
    cursor: pointer; margin-left: auto;
}

/* Settings row */
.anim-settings-row {
    display: flex;
    gap: 12px;
    padding: 8px 14px 10px;
    border-bottom: 1px solid var(--border);
}
.anim-setting-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
}
.anim-setting-group label {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.anim-setting-select, .anim-setting-input {
    font-size: 12px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    width: 100%;
}
.anim-setting-input {
    font-variant-numeric: tabular-nums;
}

/* --- Section label --- */
.anim-section-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
/* --- Generate custom sizes block (composer-only injection) --- */
.gen-sizes-block {
    border-top: 1px solid var(--border);
    padding-bottom: 14px;
}
.gen-sizes-hint {
    padding: 0 14px 10px;
    font-size: 11px;
    line-height: 1.45;
    color: var(--text-muted);
}
.gen-sizes-btn {
    margin: 0 14px;
    width: calc(100% - 28px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* --- Preset picker --- */
.anim-preset-section {
    border-bottom: 1px solid var(--border);
}

/* Type tabs (Entrance / Exit / Emphasis) */
.anim-type-tabs {
    display: flex;
    gap: 0;
    padding: 0 14px 8px;
    border-bottom: 1px solid var(--border);
}
.anim-type-tab {
    flex: 1;
    padding: 6px 0;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
}
.anim-type-tab:hover {
    color: var(--text-primary);
}
.anim-type-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Preset grid — card style */
.anim-preset-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 10px 14px 14px;
    max-height: 320px;
    overflow-y: auto;
}
.anim-preset-grid.hidden {
    display: none;
}
.anim-preset-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.15s;
}
.anim-preset-card:hover {
    border-color: var(--accent);
    background: rgba(99,102,241,0.05);
    transform: translateY(-1px);
}
.anim-preset-card.active {
    border-color: var(--accent);
    background: rgba(99,102,241,0.1);
    box-shadow: 0 0 0 1px var(--accent);
}
.anim-preset-icon {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary);
}
.anim-preset-card:hover .anim-preset-icon,
.anim-preset-card.active .anim-preset-icon {
    color: var(--accent);
}
.anim-preset-name {
    font-size: 10px;
    color: var(--text-secondary);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.anim-preset-card:hover .anim-preset-name,
.anim-preset-card.active .anim-preset-name {
    color: var(--text-primary);
}

/* --- Easing Controls --- */
.anim-easing-section {
    padding-bottom: 12px;
}
.anim-easing-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 4px 14px 8px;
}

/* --- Open Timeline button in left panel --- */
.anim-open-tl-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    color: var(--accent);
    background: rgba(99,102,241,0.08);
    border: 1px solid rgba(99,102,241,0.2);
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition);
}
.anim-open-tl-btn:hover {
    background: rgba(99,102,241,0.15);
    border-color: var(--accent);
}

/* ============================================
   Bottom Timeline Panel (btl-)
   ============================================ */
.btl-panel {
    position: relative;
    border-top: 2px solid var(--border);
    background: var(--bg-primary);
    height: 0;
    overflow: hidden;
    transition: height 0.25s ease;
    flex-shrink: 0;
}
.btl-panel.open {
    overflow: hidden;
}

/* Header */
.btl-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    height: 36px;
    flex-shrink: 0;
}
.btl-header-left,
.btl-header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}
.btl-play-btn {
    width: 26px; height: 26px;
    background: var(--accent); color: #fff; border-radius: 50%;
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--transition);
    flex-shrink: 0;
}
.btl-play-btn:hover { background: #5558e6; }
.btl-ctrl-btn {
    width: 24px; height: 24px;
    border: none; background: none; color: var(--text-secondary);
    cursor: pointer; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600;
}
.btl-ctrl-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.btl-time {
    font-size: 11px; color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    min-width: 80px;
    white-space: nowrap;
    margin-left: 4px;
}
.btl-zoom-btn {
    width: 22px; height: 22px;
    font-size: 15px; font-weight: 700;
}
.btl-zoom-label {
    font-size: 10px;
    color: var(--text-muted);
    min-width: 42px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.btl-select {
    font-size: 10px; padding: 2px 4px;
    border: 1px solid var(--border); border-radius: 4px;
    background: var(--bg-secondary); color: var(--text-primary);
    cursor: pointer;
}

/* Body: layers sidebar + tracks area */
.btl-body {
    display: flex;
    height: calc(100% - 36px);
    overflow: hidden;
}

/* Layer names column (header spacer + scrollable list) */
.btl-layers-col {
    width: 160px;
    min-width: 100px;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    flex-shrink: 0;
}
.btl-layers-resize {
    width: 4px;
    cursor: ew-resize;
    background: var(--border);
    flex-shrink: 0;
    transition: background 0.15s;
}
.btl-layers-resize:hover {
    background: var(--accent);
}
.btl-layers-header {
    height: 22px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.btl-layers {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}
.btl-layer-row {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 10px;
    border-bottom: 1px solid var(--border-subtle, rgba(0,0,0,0.06));
    overflow: hidden;
    cursor: pointer;
    user-select: none;
    transition: background 0.1s;
}
.btl-layer-row:hover {
    background: var(--bg-tertiary);
}
.btl-layer-row.active {
    background: rgba(99,102,241,0.08);
    border-left: 2px solid var(--accent);
}
.btl-layer-icon {
    color: var(--text-muted);
    display: flex;
    flex-shrink: 0;
}
.btl-layer-name {
    font-size: 11px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

/* Tracks scrollable area */
.btl-tracks-wrap {
    flex: 1;
    overflow: auto;
    position: relative;
}

/* Ruler */
.btl-ruler {
    position: sticky;
    top: 0;
    height: 22px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    z-index: 5;
    cursor: pointer;
    min-width: 100%;
}
.btl-tick {
    position: absolute;
    bottom: 0;
    width: 1px;
    height: 8px;
    background: var(--border);
}
.btl-tick-major {
    height: 14px;
    background: var(--text-muted);
}
.btl-tick-label {
    position: absolute;
    top: 2px;
    left: 3px;
    font-size: 9px;
    color: var(--text-muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}

/* Tracks scroll container (ruler stays sticky, tracks + playhead scroll) */
.btl-tracks-scroll {
    position: relative;
    min-width: 100%;
}

/* Tracks container */
.btl-tracks {
    position: relative;
    min-height: 100%;
    min-width: 100%;
}

/* Empty state */
.btl-empty {
    padding: 24px 16px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}
.btl-empty-track {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    color: var(--text-muted);
    pointer-events: none;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.15s;
}
.btl-track-row:hover .btl-empty-track {
    opacity: 0.6;
}
.btl-grid-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border-subtle, rgba(0,0,0,0.05));
    pointer-events: none;
}
.btl-track-row {
    height: 32px;
    position: relative;
    border-bottom: 1px solid var(--border-subtle, rgba(0,0,0,0.06));
    cursor: pointer;
}
.btl-track-row:hover {
    background: rgba(99,102,241,0.03);
}

/* Animation blocks */
.btl-block {
    position: absolute;
    top: 3px;
    height: calc(100% - 6px);
    border-radius: 4px;
    cursor: grab;
    display: flex;
    align-items: center;
    padding: 0 18px 0 5px;
    min-width: 10px;
    transition: box-shadow 0.12s;
    overflow: visible;
    z-index: 1;
}
.btl-block:hover {
    box-shadow: 0 0 0 1px rgba(255,255,255,0.3) inset;
    z-index: 2;
}
.btl-block.selected {
    box-shadow: 0 0 0 2px var(--accent), 0 0 0 3px rgba(99,102,241,0.25);
    z-index: 3;
}
.btl-block.dragging {
    cursor: grabbing;
    opacity: 0.85;
    z-index: 4;
}

/* Color classes */
.btl-bar-entrance { background: #5B53E8; }
.btl-bar-exit { background: #f43f5e; }
.btl-bar-emphasis { background: #f59e0b; }
.btl-bar-motion { background: #10b981; }

/* Block label */
.btl-block-label {
    font-size: 9px;
    color: rgba(255,255,255,0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    font-weight: 500;
    flex: 1;
    min-width: 0;
}

/* Resize handles */
.btl-handle {
    position: absolute;
    top: 0;
    width: 6px;
    height: 100%;
    cursor: ew-resize;
    z-index: 4;
    border-radius: 2px;
}
.btl-handle-l { left: -1px; }
.btl-handle-r { right: -1px; }
.btl-handle:hover {
    background: rgba(255,255,255,0.45);
}

/* Playhead */
.btl-playhead {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    z-index: 10;
    pointer-events: none;
    left: 0;
}
.btl-playhead-line {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 2px;
    background: #ef4444;
    border-radius: 1px;
}
.btl-playhead::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -5px;
    width: 12px;
    height: 10px;
    background: #ef4444;
    clip-path: polygon(0 0, 100% 0, 50% 100%);
}

/* Drag tooltip */
.btl-tooltip {
    position: fixed;
    background: rgba(0,0,0,0.88);
    color: #fff;
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 4px;
    pointer-events: none;
    z-index: 10000;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Sync scroll between layers and tracks */
.btl-layers::-webkit-scrollbar,
.btl-tracks-wrap::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

/* Resize handle (top edge of panel) */
.btl-resize-handle {
    position: absolute;
    top: -3px; left: 0; right: 0;
    height: 6px;
    cursor: ns-resize;
    z-index: 20;
}
.btl-resize-handle:hover {
    background: rgba(99,102,241,0.3);
}

/* Dropdown menus (preset picker, context menu, add animation) */
.btl-dropdown {
    position: fixed;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 10001;
    min-width: 160px;
    max-height: 380px;
    overflow-y: auto;
    padding: 4px 0;
}
.btl-dropdown-header {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    padding: 8px 12px 4px;
}
.btl-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 12px;
    font-size: 12px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.1s;
}
.btl-dropdown-item:hover {
    background: var(--bg-tertiary);
}
.btl-dropdown-item.active {
    color: var(--accent);
    font-weight: 600;
}
.btl-dropdown-item.active::before {
    content: '\2713';
    margin-right: 4px;
    font-size: 11px;
}
.btl-dropdown-item.danger {
    color: #dc2626;
}
.btl-dropdown-item.danger:hover {
    background: rgba(220,38,38,0.08);
}
.btl-hint {
    font-size: 10px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.btl-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}
.btl-dropdown-easing {
    display: flex;
    gap: 6px;
    padding: 6px 12px;
}
.btl-dd-ease-curve,
.btl-dd-ease-type {
    font-size: 11px;
    padding: 3px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    flex: 1;
}

/* Stagger row in left panel */
.anim-stagger-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px 10px;
    border-bottom: 1px solid var(--border);
}
.anim-stagger-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.anim-stagger-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(99,102,241,0.06);
}
.anim-stagger-opts {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: var(--text-muted);
}
.anim-stagger-opts label {
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ============================================
   Layers Panel Enhanced
   ============================================ */
.layers-list-item {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 12px; cursor: pointer; border-bottom: 1px solid var(--border-subtle);
    user-select: none;
}
.layers-list-item:hover { background: var(--bg-tertiary); }
.layers-list-item.active { background: rgba(99,102,241,0.08); border-left: 2px solid var(--accent); }
.layers-list-item.dragging { opacity: 0.5; background: rgba(99,102,241,0.15); }
.layers-list-item.drag-over { border-top: 2px solid var(--accent); }
.layer-name {
    flex: 1; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* A text layer: its name, and under it the text itself — one line, cut with … (2026-11-08) */
.layer-name-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.layer-name-wrap .layer-name { flex: none; }
.layer-text-preview { font-size: 10.5px; line-height: 1.3; color: var(--text-muted, #6b7280); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer-name-wrap.is-child .layer-text-preview { padding-left: 0.6em; }
/* Catalog template mode: per-layer binding tag + conditions marker in the row */
.layer-bind-tag {
    flex: 0 0 auto; font-size: 9.5px; font-weight: 600;
    color: #5b4ec4; background: #f1efff; border: 1px solid #e2dcfb;
    border-radius: 4px; padding: 1px 5px;
    max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.layer-bind-tag.is-img { color: #0a7d4b; background: #e9f9f0; border-color: #c7eed9; }
.layer-rule-badge { flex: 0 0 auto; font-size: 10px; color: #b4640a; }
/* Conditions FAIL for the current preview product → layer hidden on canvas
   right now; the flag goes muted-indigo so the list explains why. */
.layer-rule-badge.is-cond-hidden { color: #5B53E8; opacity: 0.75; }
/* Video templates: ⚡ = animated layer; chip = the scene it belongs to */
.layer-motion-badge { flex: 0 0 auto; font-size: 10px; color: #5B53E8; }
.layer-scene-tag {
    flex: 0 0 auto; font-size: 9px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .02em; color: #0e7490; background: #ecfeff; border: 1px solid #bae6fd;
    border-radius: 4px; padding: 1px 4px; max-width: 70px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.layer-scene-tag.is-all { color: #5B53E8; background: #f0efff; border-color: #dcd9fb; }
/* Frames: which frame's layers the list is showing (others are hidden on the canvas). */
.layers-frame-note {
    font-size: 11px; color: var(--text-secondary); background: var(--bg-secondary);
    border: 1px solid var(--border); border-radius: 6px;
    padding: 5px 8px; margin: 0 0 6px; line-height: 1.35;
}
.layer-name-input {
    flex: 1; font-size: 12px; padding: 1px 4px;
    border: 1px solid var(--accent); border-radius: 3px;
    background: var(--bg-secondary); color: var(--text-primary); outline: none;
}
.layer-actions {
    display: flex; gap: 2px; opacity: 0.35;
    transition: opacity var(--transition);
}
.layers-list-item:hover .layer-actions { opacity: 1; }
.layer-action-btn.active { color: var(--accent); opacity: 1; }
.layer-action-btn {
    width: 22px; height: 22px; border: none; background: none;
    color: var(--text-muted); cursor: pointer; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
}
.layer-action-btn:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.layer-action-btn.active { color: var(--accent); }
.layer-thumb {
    width: 28px; height: 28px; border-radius: 4px;
    background: var(--bg-tertiary); border: 1px solid var(--border-subtle);
    overflow: hidden; flex-shrink: 0;
}
.layer-thumb img { width: 100%; height: 100%; object-fit: contain; }

/* ============================================
   Brand Kit Panel (Editor)
   ============================================ */
.brand-panel-section {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.brand-panel-section h4 {
    font-size: 11px; font-weight: 600; color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px;
}
.brand-colors-row {
    display: flex; gap: 6px; flex-wrap: wrap;
}
.brand-color-swatch {
    width: 28px; height: 28px; border-radius: 6px;
    border: 2px solid var(--border); cursor: pointer;
    transition: transform var(--transition);
}
.brand-color-swatch:hover { transform: scale(1.15); border-color: var(--accent); }
.brand-fonts-list {
    display: flex; flex-direction: column; gap: 4px;
}
.brand-logos-row {
    display: flex; gap: 8px;
}
.brand-logo-thumb {
    width: 48px; height: 48px; border-radius: 6px;
    border: 1px solid var(--border); overflow: hidden; cursor: pointer;
    background: var(--bg-tertiary);
}
.brand-logo-thumb img { width: 100%; height: 100%; object-fit: contain; }

/* Brand Kit editor panel sub-tabs */
.brand-kit-selector {
    padding: 0 12px;
    margin-bottom: 4px;
}
.brand-kit-selector select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}
.brand-subtabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    padding: 0;
    gap: 0;
    overflow: hidden;
}
.brand-subtab {
    flex: 1;
    padding: 8px 4px;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    font: inherit;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    text-align: center;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
}
.brand-subtab:hover { color: var(--text-secondary); }
.brand-subtab.active { color: var(--accent); border-bottom-color: var(--accent); }
.brand-subtab-content { display: none; }
.brand-subtab-content.active { display: block; }
.brand-upload-area {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    margin: 12px;
}
.brand-upload-area:hover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.04);
}
.brand-upload-area svg { color: var(--text-muted); margin-bottom: 6px; }
.brand-upload-area p { font-size: 13px; color: var(--text-primary); margin: 0 0 2px; }
.brand-upload-area span { font-size: 11px; color: var(--text-muted); }

/* Layer Context Menu */
.layer-context-menu {
    position: fixed;
    z-index: 10000;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    padding: 4px 0;
    min-width: 160px;
}
.layer-ctx-item {
    padding: 7px 14px;
    font-size: 12px;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.layer-ctx-item:hover { background: var(--bg-tertiary); }
.layer-ctx-danger { color: var(--danger); }
.layer-ctx-danger:hover { background: rgba(239, 68, 68, 0.08); }
.layer-ctx-disabled { opacity: 0.4; pointer-events: none; }
.layer-ctx-separator {
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 0;
}

/* Group editing indicator (floating bar on canvas) */
.group-edit-indicator {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--accent);
    color: #fff;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    pointer-events: none;
    animation: groupIndicatorIn 0.2s ease-out;
}
@keyframes groupIndicatorIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Group hint box in right panel */
.group-hint-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.3;
}
.group-hint-box.active {
    background: rgba(99, 102, 241, 0.08);
    color: var(--accent);
    border: 1px solid rgba(99, 102, 241, 0.15);
}

/* Group action buttons row */
.group-actions-row {
    display: flex;
    gap: 6px;
    margin-bottom: 4px;
}
.group-action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    border: 1.5px solid var(--border-subtle);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s ease;
}
.group-action-btn:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}
.group-action-btn.group-action-create {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.group-action-btn.group-action-create:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}
.group-action-btn.group-action-enter {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.group-action-btn.group-action-enter:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}
.group-action-btn.group-action-exit {
    background: var(--bg-secondary);
    color: var(--accent);
    border-color: var(--accent);
}
.group-action-btn.group-action-exit:hover {
    background: rgba(99, 102, 241, 0.08);
}
.group-action-btn.group-action-ungroup {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-color: var(--border-subtle);
}
.group-action-btn.group-action-ungroup:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
}
.panel-section-sub h4 {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

/* Layer child items (group sub-objects) */
.layers-list-item.layer-child {
    border-left: 2px solid var(--border-subtle);
    margin-left: 12px;
    font-size: 11px;
    padding-top: 4px;
    padding-bottom: 4px;
    opacity: 0.85;
}
.layers-list-item.layer-child.active {
    border-left-color: var(--accent);
    opacity: 1;
}

/* --- Alignment buttons --- */
.align-buttons {
    display: flex;
    gap: 2px;
    align-items: center;
}
.align-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 6px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.align-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent);
}
.align-btn.active {
    background: var(--accent-subtle);
    color: var(--accent);
    border-color: var(--accent);
}
.align-sep {
    width: 1px;
    height: 18px;
    background: var(--border);
    margin: 0 4px;
}

/* --- Filter presets row --- */
.filter-presets-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.filter-preset-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    cursor: pointer;
    transition: all var(--transition);
    width: 54px;
}
.filter-preset-btn:hover {
    border-color: var(--accent);
    background: var(--accent-subtle);
}
/* Active look — shows which preset is currently applied (was invisible before). */
.filter-preset-btn.is-on {
    border-color: var(--accent);
    background: var(--accent-subtle);
    box-shadow: 0 0 0 1px var(--accent) inset;
}
.filter-preset-btn small {
    font-size: 9px;
    color: var(--text-muted);
}
.filter-preset-btn.is-on small { color: var(--accent); font-weight: 700; }
.filter-swatch {
    width: 36px;
    height: 24px;
    border-radius: 3px;
    display: block;
}

/* --- Text effect preset gallery (Canva-style one-click looks) --- */
.cb-txfx-gallery { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.cb-txfx-tile {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: none; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 4px; cursor: pointer; transition: all var(--transition); width: 54px;
}
.cb-txfx-tile:hover { border-color: var(--accent); background: var(--accent-subtle); }
.cb-txfx-tile.is-on { border-color: var(--accent); background: var(--accent-subtle); box-shadow: inset 0 0 0 1px var(--accent); }
.cb-txfx-tile small { font-size: 9px; color: var(--text-muted); }
.cb-txfx-tile.is-on small { color: var(--accent); }
.cb-txfx-prev {
    width: 44px; height: 26px; display: flex; align-items: center; justify-content: center;
    border-radius: 3px; background: #f4f5fb; color: #1a1a2e;
    font-weight: 800; font-size: 15px; line-height: 1; overflow: hidden;
}
.cb-txfx-prev--shadow  { text-shadow: 2px 2px 2px rgba(0,0,0,0.45); }
.cb-txfx-prev--outline { color: #fff; -webkit-text-stroke: 1.4px #1a1a2e; }
.cb-txfx-prev--hollow  { color: transparent; -webkit-text-stroke: 1.4px #1a1a2e; }
.cb-txfx-prev--glow    { color: #6c5ce7; text-shadow: 0 0 7px #6c5ce7; }
.cb-txfx-prev--neon    { color: #00e5ff; text-shadow: 0 0 4px #00e5ff, 0 0 9px #00e5ff; }
.cb-txfx-prev--bg      { color: #1a1a2e; background: #ffeb3b; }

/* Shape effect preset previews — a small block in the same tile/stage as the text
   gallery, styled to show shadow / glow / neon / outline. Reuses .cb-txfx-prev base. */
.cb-shfx-block { display: block; width: 20px; height: 14px; border-radius: 3px; background: #6b7280; }
.cb-shfx-prev--none .cb-shfx-block    { background: #9ca3af; }
.cb-shfx-prev--shadow .cb-shfx-block  { box-shadow: 2px 2px 3px rgba(0,0,0,0.45); }
.cb-shfx-prev--glow .cb-shfx-block    { background: #5B53E8; box-shadow: 0 0 7px #5B53E8; }
.cb-shfx-prev--neon .cb-shfx-block    { background: #00e5ff; box-shadow: 0 0 4px #00e5ff, 0 0 9px #00e5ff; }
.cb-shfx-prev--outline .cb-shfx-block { background: transparent; border: 2px solid #1a1a2e; }

/* --- Canvas context menu --- */
.canvas-context-menu {
    min-width: 200px;
    animation: ctxFadeIn 0.12s ease;
}
@keyframes ctxFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
.canvas-context-menu .context-menu-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.canvas-context-menu .ctx-shortcut {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 16px;
}
.context-menu-sep {
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 0;
}
.context-menu-item.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* --- Brand font items enhanced --- */
.brand-font-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition);
    border: 1px solid transparent;
}
.brand-font-item:hover {
    background: var(--bg-hover);
    border-color: var(--border);
}
.brand-font-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.brand-font-role {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}
.brand-font-preview {
    font-size: 15px;
    line-height: 1.3;
}
.brand-font-desc {
    font-size: 10px;
    color: var(--text-muted);
}
.brand-font-apply {
    opacity: 0;
    transition: opacity var(--transition);
}
.brand-font-item:hover .brand-font-apply {
    opacity: 1;
}

/* --- Brand Typography Cards --- */
.brand-typo-card {
    background: var(--bg-hover);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
}
.brand-typo-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.brand-typo-role {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}
/* .btn-xs consolidated into css/app.css (single canonical .btn modifier). */
.brand-typo-preview {
    padding: 4px 0 8px;
    color: var(--text-primary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.brand-typo-controls { display: flex; flex-direction: column; gap: 6px; }
.brand-typo-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.brand-typo-row > label {
    font-size: 10px;
    color: var(--text-muted);
    width: 32px;
    flex-shrink: 0;
}
.brand-typo-font-btn {
    flex: 1;
    text-align: left;
    padding: 4px 8px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-primary);
    cursor: pointer;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: border-color var(--transition);
}
.brand-typo-font-btn:hover { border-color: var(--accent); }
.brand-typo-row-split { display: flex; gap: 6px; }
.brand-typo-field {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
}
.brand-typo-field label {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
}
.brand-typo-size {
    width: 52px;
    padding: 3px 4px;
    font-size: 11px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    text-align: center;
}
.brand-typo-weight {
    flex: 1;
    padding: 3px 4px;
    font-size: 11px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* --- Document colors --- */
.doc-colors-row {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.doc-color-swatch {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid var(--border);
    cursor: pointer;
    padding: 0;
    transition: transform 0.15s;
}
.doc-color-swatch:hover {
    transform: scale(1.2);
    border-color: var(--accent);
}

/* --- Gradient settings --- */
.gradient-settings {
    padding: 4px 0;
}
.gradient-settings.collapsed {
    display: none;
}

/* --- Export checkbox --- */
.export-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
}
.export-checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

/* --- Collapsed helper (for non-animated sections) --- */
.prop-row.collapsed,
.gradient-settings.collapsed,
#export-transparent-row.collapsed {
    display: none;
}

/* --- Toast Notifications --- */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    background: #333;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    opacity: 0;
    transform: translateY(12px) scale(0.96);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: auto;
    white-space: nowrap;
}
.toast-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.toast-exit {
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
}
.toast-icon { display: flex; flex-shrink: 0; }
.toast-success { background: #1b8a3a; }
.toast-error { background: #c62828; }
.toast-info { background: #37474f; }
.toast-warn { background: #e65100; }
.toast-success::before { content: '\2713'; margin-right: 6px; font-weight: bold; }
.toast-error::before { content: '\2715'; margin-right: 6px; font-weight: bold; }
.toast-info::before { content: '\2139'; margin-right: 6px; font-weight: bold; }
.toast-warn::before { content: '\26A0'; margin-right: 6px; }

/* --- Crop Tool --- */
.crop-pos-btn {
    width: 100%;
    aspect-ratio: 1;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
}
.crop-pos-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}
.crop-action-bar {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(30,30,30,0.92);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    white-space: nowrap;
    z-index: 100;
}

/* --- Shadow Compass --- */
.shadow-compass {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    width: 90px;
}
.compass-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s, border-color 0.15s;
}
.compass-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}
.compass-center {
    font-size: 8px;
    color: var(--text-muted);
}
.compass-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.shadow-cut-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}
.shadow-cut-btn {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 4px 12px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    transition: all 0.15s;
}
.shadow-cut-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.shadow-cut-hint {
    font-size: 11px;
    color: var(--text-muted);
}

/* ===== Eyedropper button ===== */
.eyedropper-btn {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    flex-shrink: 0;
    transition: all 0.15s;
}
.eyedropper-btn:hover {
    background: var(--bg-tertiary);
    color: var(--accent);
    border-color: var(--accent);
}

/* ===== Aspect lock button ===== */
.aspect-lock-btn {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    flex-shrink: 0;
    transition: all 0.15s;
    margin: 0 4px;
}
.aspect-lock-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}
.aspect-lock-btn.active,
.aspect-lock-btn[data-locked="true"] {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ===== Multi-stop gradient editor ===== */
.grad-stops-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 6px;
}
.grad-stop-row {
    display: flex;
    align-items: center;
    gap: 4px;
}
.grad-stop-row .grad-stop-color {
    width: 32px;
    height: 24px;
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}
.grad-stop-row .grad-stop-pos,
.grad-stop-row .grad-stop-opacity {
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-tertiary);
    border-radius: 2px;
    outline: none;
}
.grad-stop-row .grad-stop-pos::-webkit-slider-thumb,
.grad-stop-row .grad-stop-opacity::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}
.grad-stop-remove {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    padding: 0;
    flex-shrink: 0;
    transition: all 0.15s;
}
.grad-stop-remove:hover {
    background: #fee;
    color: #e74c3c;
}

/* ===== Recent colors palette ===== */
.recent-colors-row {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    padding: 2px 0;
}
.recent-color-swatch {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
}
.recent-color-swatch:hover {
    transform: scale(1.2);
    box-shadow: 0 0 0 2px var(--accent);
}

/* ===== Rulers ===== */
.ruler {
    background: var(--bg-secondary);
    position: absolute;
    z-index: 10;
    overflow: hidden;
    user-select: none;
}
.ruler-horizontal {
    top: 0;
    left: 20px;
    height: 20px;
    right: 0;
    cursor: s-resize;
    border-bottom: 1px solid var(--border-subtle);
}
.ruler-vertical {
    top: 20px;
    left: 0;
    width: 20px;
    bottom: 0;
    cursor: e-resize;
    border-right: 1px solid var(--border-subtle);
}
.ruler-corner {
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
    z-index: 11;
}

/* --- Save Indicator (unsaved changes dot) --- */
#save-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    right: -2px;
    background: transparent;
    transition: background 0.2s ease;
    pointer-events: none;
}
#save-indicator.unsaved {
    background: var(--accent-secondary, #e8502f);
}

/* --- Space+drag panning cursor --- */
.gen-workspace[style*="cursor: grab"] .gen-artboard,
.gen-workspace[style*="cursor: grab"] .gen-artboard * {
    cursor: inherit !important;
}
.gen-workspace[style*="cursor: grabbing"] .gen-artboard,
.gen-workspace[style*="cursor: grabbing"] .gen-artboard * {
    cursor: inherit !important;
}

/* --- Editor loading overlay (size switch) --- */
.editor-size-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.7);
    z-index: 50;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}
.editor-size-loading.visible {
    opacity: 1;
}
.editor-size-loading .spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Adapt arrow hover highlight --- */
.gen-adapt-arrow-btn:hover {
    background: var(--accent-secondary-hover);
    transform: translateY(-50%) scale(1.08);
}

/* --- Push Changes modal enhancements --- */
.push-modal-body {
    max-height: 50vh;
    overflow-y: auto;
}
.push-size-row {
    transition: background 0.1s ease;
}

/* --- Keyboard Shortcuts Modal --- */
.shortcuts-section {
    margin-bottom: 16px;
}
.shortcut-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid var(--border-subtle, rgba(0,0,0,0.04));
}
.shortcut-row span:first-child {
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 1px 6px;
    border-radius: 3px;
    border: 1px solid var(--border);
    white-space: nowrap;
}
.shortcut-row span:last-child {
    color: var(--text-primary);
    text-align: right;
}

/* --- Disabled Button States --- */
.toolbar-btn:disabled,
.toolbar-btn.disabled,
.right-panel button:disabled,
.right-panel button.disabled,
.left-panel button:disabled,
.left-panel button.disabled,
.export-dialog button:disabled,
.export-dialog button.disabled,
.btn:disabled,
.btn.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* ==================== Sync Mode Dropdown ==================== */
.toolbar-sync-mode {
    font-size: 11px;
    padding: 3px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-secondary);
    cursor: pointer;
    outline: none;
    max-width: 190px;
}
.toolbar-sync-mode:focus {
    border-color: var(--accent);
}

/* ==================== Push Mode Selector ==================== */
.push-mode-section {
    padding: 10px 18px;
    border-bottom: 1px solid var(--border-subtle);
}
.push-mode-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.push-mode-row {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.push-mode-btn {
    padding: 5px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text-secondary);
}
.push-mode-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}
.push-mode-btn.active {
    background: var(--accent-subtle);
    color: var(--accent);
    border-color: var(--accent);
    font-weight: 600;
}

/* ==================== Size Context Menu ==================== */
.size-context-menu {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    padding: 4px;
    z-index: 10000;
}
.size-ctx-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 12px;
    border: none;
    background: none;
    font-size: 12px;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    text-align: left;
    white-space: nowrap;
}
.size-ctx-item:hover {
    background: var(--bg-hover);
}
.size-ctx-item svg {
    flex-shrink: 0;
    color: var(--text-muted);
}
/* A menu row that explains itself: the label, then why you would pick it. Cheaper than a
   tooltip, which never appears on a menu you dismiss in half a second. */
.size-ctx-hint { margin-left: auto; padding-left: 14px; font-size: 10.5px; color: var(--text-muted); }
.size-ctx-item:disabled { opacity: .45; cursor: default; }
.size-ctx-item:disabled:hover { background: none; }
/* A PINNED frame — its layers ride above every other frame for the whole clip. Marked on the
   card itself so the state is visible in the strip rather than only in the right-click menu. */
.cb-frm-card.is-pinned { border-color: var(--accent, #5B53E8); box-shadow: 0 0 0 1px var(--accent, #5B53E8) inset; }
.cb-frm-card.is-pinned::after {
    content: '📌'; position: absolute; top: 4px; right: 5px; font-size: 11px; line-height: 1;
    pointer-events: none;
}
.size-ctx-danger {
    color: #dc2626;
}
.size-ctx-danger svg {
    color: #dc2626;
}
.size-ctx-danger:hover {
    background: rgba(239, 68, 68, 0.08);
}
.size-ctx-separator {
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 8px;
}

/* ==================== Sizes Panel Override Indicator ==================== */
.sizes-item-overrides {
    font-size: 10px;
    color: var(--accent);
    background: var(--accent-subtle);
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 500;
    margin-left: auto;
}

/* ==================== Adapt Menu Improvements ==================== */
.adapt-menu {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    padding: 4px;
    z-index: 10000;
}
.adapt-menu-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 6px 12px 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.adapt-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 12px;
    border: none;
    background: none;
    font-size: 12px;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    text-align: left;
}
.adapt-menu-item:hover {
    background: var(--bg-hover);
}

/* =============================================================================
 * Floating contextual toolbar
 *
 * Canva-style hover toolbar that floats above the active selection. Lives
 * inside .canvas-area as `position: absolute`, pixel-positioned by JS
 * (updateFloatingToolbar) using the canvas's getBoundingClientRect to
 * translate canvas coords → screen coords.
 *
 * Visually a compact white pill with a soft shadow + dividers between
 * action groups. Buttons are 28×28 with 14×14 icons; danger variant is
 * red, active variant uses indigo bg.
 * ============================================================================= */
.floating-toolbar {
    position: absolute;
    display: none;                 /* shown by JS once positioned */
    align-items: center;
    gap: 2px;
    padding: 4px 6px;
    background: var(--bg-secondary, #fff);
    border: 1px solid var(--border, #e0e0e6);
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(15, 23, 42, 0.12);
    z-index: 200;                  /* above guides + adapt buttons */
    pointer-events: auto;
    white-space: nowrap;
    font: inherit;
    user-select: none;
    animation: ftFadeIn 0.12s ease-out;
}
/* Suppress the fade-in animation on re-positions (drag-end, scroll, zoom)
 * so the toolbar doesn't pulse every time. JS adds this class after the
 * first position and removes it on hide. */
.floating-toolbar.ft-no-anim { animation: none; }

@keyframes ftFadeIn {
    from { opacity: 0; transform: translateY(2px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ft-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-primary, #1a1a2e);
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.ft-btn:hover {
    background: var(--bg-hover, #ededf0);
}
.ft-btn.is-active {
    background: var(--accent-subtle, rgba(99,102,241,0.1));
    color: var(--accent, #5B53E8);
}
.ft-btn.is-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger, #ef4444);
}

.ft-sep {
    width: 1px;
    height: 18px;
    background: var(--border, #e0e0e6);
    margin: 0 2px;
}

.ft-color-swatch {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.ft-font-label {
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11.5px;
    line-height: 1;
}

.ft-opacity-label {
    font-size: 10px;
    margin-left: 2px;
    color: var(--text-secondary, #666);
}

/* Popovers anchored under the toolbar (color picker, opacity slider).
 * Appended to document.body so they escape any overflow:hidden parents. */
.ft-popover {
    position: fixed;
    background: var(--bg-secondary, #fff);
    border: 1px solid var(--border, #e0e0e6);
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.15);
    z-index: 1500;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ft-popover-recent {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.ft-popover-swatch {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    cursor: pointer;
    padding: 0;
}
.ft-popover-swatch:hover {
    border-color: var(--accent, #5B53E8);
    transform: scale(1.06);
}

/* ============================================
   Lint Panel — Meta + WCAG creative quality gates
   ============================================ */
.lint-toolbar-btn {
    position: relative;
}
.lint-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    background: #f59e0b;
    color: #fff;
    box-shadow: 0 0 0 2px var(--bg, #fff);
}
.lint-badge[data-severity="block"] { background: #dc2626; }

.lint-panel {
    position: fixed;
    top: 64px;
    right: 12px;
    width: 360px;
    max-height: calc(100vh - 96px);
    background: var(--bg-secondary, #fff);
    border: 1px solid var(--border, #e0e0e6);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
    z-index: 1400;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-size: 13px;
}
.lint-panel.open { display: flex; }
.lint-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border, #e0e0e6);
}
.lint-panel-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text, #1f2937);
}

.lint-panel-summary {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-faint, #f1f5f9);
}
.lint-summary-ok {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #047857;
    font-weight: 500;
}
.lint-summary-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #d1fae5;
    color: #047857;
    font-weight: 700;
}
.lint-summary-counts {
    display: flex;
    gap: 6px;
}
.lint-pill {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
}
.lint-pill.block { background: #fee2e2; color: #b91c1c; }
.lint-pill.warn  { background: #fef3c7; color: #92400e; }

.lint-panel-list {
    list-style: none;
    margin: 0;
    padding: 6px 0;
    overflow-y: auto;
    flex: 1;
}
.lint-item {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-faint, #f1f5f9);
    cursor: pointer;
    transition: background 0.12s;
}
.lint-item:hover { background: var(--bg-hover, #f9fafb); }
.lint-item[data-element-id] { cursor: pointer; }
.lint-item:not([data-element-id]) { cursor: default; }
.lint-item-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.lint-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.lint-dot.block { background: #dc2626; }
.lint-dot.warn  { background: #f59e0b; }
.lint-dot.pass  { background: #10b981; }
.lint-item-title {
    font-weight: 600;
    color: var(--text, #1f2937);
}
.lint-item-detail {
    margin: 0 0 4px 16px;
    color: var(--text-muted, #6b7280);
    font-size: 12px;
    line-height: 1.4;
}
.lint-item-fix {
    margin: 0 0 0 16px;
    color: var(--text, #374151);
    font-size: 12px;
    line-height: 1.4;
}
.lint-item-fix strong { color: var(--accent, #5B53E8); }

.lint-panel-footer {
    padding: 8px 14px;
    border-top: 1px solid var(--border-faint, #f1f5f9);
    background: var(--bg, #fafbfc);
}
.lint-footnote {
    font-size: 11px;
    color: var(--text-muted, #9ca3af);
}

/* ── Video template motion: mode toggle, style cards, timeline dock ────────── */
.cb-anim-subhead {
    font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-muted, #9ca3af); margin: 10px 0 4px;
}
.cb-anim-section .cb-anim-subhead:first-of-type { margin-top: 4px; }
.cb-vmode-seg {
    display: flex; gap: 0; border: 1px solid var(--border-color, #e5e7eb); border-radius: 8px;
    overflow: hidden; margin-bottom: 10px;
}
.cb-vmode-btn {
    flex: 1; padding: 6px 0; font-size: 12px; font-weight: 600; border: none;
    background: transparent; color: var(--text-secondary, #6b7280); cursor: pointer;
}
.cb-vmode-btn + .cb-vmode-btn { border-left: 1px solid var(--border-color, #e5e7eb); }
.cb-vmode-btn.is-on { background: #eef2ff; color: #4f46e5; }
.cb-vstyle-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cb-vstyle-card {
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
    padding: 8px 9px; border: 1px solid var(--border-color, #e5e7eb); border-radius: 9px;
    background: var(--bg-primary, #fff); cursor: pointer; text-align: left;
}
.cb-vstyle-card:hover { border-color: #c7d2fe; background: #fafbff; }
.cb-vstyle-card.is-on { border-color: #5B53E8; background: #eef2ff; }
.cb-vstyle-name { font-size: 12px; font-weight: 700; color: var(--text-primary, #111827); }
.cb-vstyle-desc { font-size: 10.5px; color: var(--text-muted, #9ca3af); line-height: 1.25; }

/* ── Bottom dock: Timeline / Motion / Conditions / Effects under the canvas ──
   INTEGRATED into the editor chrome: grid row 2 of .generator-view, full
   width, directly above the zoom bar. Collapsing leaves just the tab bar. */
.cb-bdock {
    grid-row: 2; min-width: 0;
    background: var(--bg-primary, #fff);
    border-top: 1px solid var(--border-color, #e5e7eb);
    user-select: none;
}
/* Fallback when the generator view isn't mounted: the old floating card. */
.cb-bdock--float {
    position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
    width: clamp(520px, 62vw, 1100px); z-index: 600;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 12px; box-shadow: 0 12px 32px rgba(15, 23, 42, .18);
}
/* Inside the editor the dock can NEVER float — parent-scoped override wins
   even if a stale --float class lingers from an early mount. */
.generator-view > .cb-bdock {
    position: static; bottom: auto; left: auto; transform: none;
    width: auto; z-index: auto;
    border: none; border-top: 1px solid var(--border-color, #e5e7eb);
    border-radius: 0; box-shadow: none;
}

/* Dock-width layouts: the per-layer sections were designed for a 320px side
   panel — use the dock's full width instead of stacking one long column. */
.cb-bdock-pane .cb-anim-section {
    display: flex; flex-wrap: wrap; align-items: flex-start;
    column-gap: 30px; row-gap: 6px;
}
.cb-bdock-pane .cb-anim-section > h3 { flex: 0 0 100%; margin: 0 0 2px; }
.cb-anim-grp { min-width: 0; flex: 0 1 auto; }
.cb-bdock-pane .cb-anim-fine { flex: 1 1 340px; max-width: 480px; }
.cb-bdock-pane .cb-anim-section .cb-anim-foot { flex: 0 0 100%; margin-top: 4px; }
.cb-bdock-pane .cb-anim-section > .btn-full { width: auto; flex: 0 0 auto; align-self: flex-end; }
.cb-bdock-bar {
    display: flex; align-items: center; gap: 4px; padding: 6px 8px;
    border-bottom: 1px solid var(--border-subtle, #eef0f4);
}
.cb-bdock.is-collapsed .cb-bdock-bar { border-bottom: none; }
.cb-bdock-tab {
    border: none; background: transparent; padding: 5px 11px; border-radius: 7px;
    font-size: 12px; font-weight: 600; color: var(--text-secondary, #6b7280);
    cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.cb-bdock-tab:hover { background: #f3f4f6; }
.cb-bdock-tab.active { background: #eef2ff; color: #4338ca; }
/* Onion-skin toggle — sits beside the Frames tab and reads as a control, not another tab:
   lighter weight, an outline when off, and a filled accent when on so its state is obvious at a
   glance rather than only in the tooltip. */
.cb-bdock-ghost {
    margin-left: 4px; padding: 4px 9px; border-radius: 7px; cursor: pointer;
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11.5px; font-weight: 600;
    border: 1px solid var(--border-color, #e5e7eb); background: transparent;
    color: var(--text-secondary, #6b7280);
}
.cb-bdock-ghost:hover { background: #f3f4f6; color: var(--text-primary, #111827); }
.cb-bdock-ghost.is-on {
    background: #eef2ff; border-color: #c7d2fe; color: #4338ca;
}
.cb-bdock-ghost svg { opacity: .85; }
@container (max-width: 520px) { .cb-bdock-ghost span { display: none; } }
.cb-bdock-count {
    font-style: normal; font-size: 9.5px; font-weight: 700; line-height: 1;
    color: #5b4ec4; background: #f1efff; border-radius: 999px; padding: 2px 5px;
}
.cb-bdock-ctx {
    margin-left: auto; font-size: 11px; color: var(--text-muted, #9ca3af);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px;
}
.cb-bdock-collapse {
    border: none; background: transparent; cursor: pointer; font-size: 14px;
    line-height: 1; color: var(--text-secondary, #6b7280); padding: 4px 8px;
}
.cb-bdock-collapse:hover { color: var(--text-primary, #111827); }
.cb-bdock-body { padding: 8px 10px 10px; }
.cb-bdock.is-collapsed .cb-bdock-body { display: none; }
.cb-bdock-pane { display: none; position: relative; overflow: auto; }
/* ── DOCK RESIZE ───────────────────────────────────────────────────────────
   A grab handle on the dock's top edge. Without one the dock had two sizes, 300px and
   collapsed, which is not enough for a strip that holds up to six frames. */
.cb-bdock-grip {
    height: 7px; margin-bottom: -1px; cursor: ns-resize;
    display: flex; align-items: center; justify-content: center;
    background: transparent; touch-action: none;
}
.cb-bdock-grip::before {
    content: ''; width: 46px; height: 3px; border-radius: 2px;
    background: #d7dce6; transition: background .12s, width .12s;
}
.cb-bdock-grip:hover::before { background: #a9b3c6; width: 62px; }
.cb-bdock-grip.is-dragging::before { background: #5B53E8; width: 62px; }
.cb-bdock.is-collapsed .cb-bdock-grip { cursor: pointer; }

/* --bdock-h is set by the drag; the pane takes what is left after the bar and the grip.
   Untouched, it keeps the original 300px cap and sizes to its content.

   HEIGHT, not max-height: the dock is an `auto` grid row, so it is sized by its content —
   raising a maximum the content never reaches grew nothing, and dragging the handle upward
   did visibly nothing at all. */
.cb-bdock-pane { max-height: 300px; }
.cb-bdock[style*="--bdock-h"] .cb-bdock-pane {
    max-height: none;
    height: calc(var(--bdock-h) - 48px);
}
/* A short dock spends less of itself on the header. */
.cb-frm-pane.is-compact .cb-frm-head { padding: 5px 12px; margin-bottom: 6px; }
.cb-frm-pane.is-compact .cb-frm-fx__sel { padding-top: 3px; padding-bottom: 3px; }

.cb-bdock-pane.active { display: block; }
/* Sections docked flush — they carry their own headings. */
.cb-bdock-pane .panel-section { border: none; padding: 2px 0 0; margin: 0; }
.cb-bdock-hint {
    font-size: 12px; color: var(--text-muted, #9ca3af);
    padding: 18px 6px; text-align: center;
}

/* (legacy floating-timeline box — the timeline now lives in a .cb-bdock pane;
   the inner .cb-vtl-* row/lane/bar styles below are still in use) */
.cb-vtl {
    position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
    width: clamp(440px, 52vw, 920px); z-index: 600;
    background: var(--bg-primary, #fff); border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 12px; box-shadow: 0 12px 32px rgba(15, 23, 42, .18);
    padding: 8px 10px 10px; user-select: none;
}
.cb-vtl-head { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; }
.cb-vtl-btn {
    border: 1px solid var(--border-color, #e5e7eb); background: var(--bg-primary, #fff);
    border-radius: 7px; width: 26px; height: 24px; font-size: 12px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; color: var(--text-primary, #111827);
}
.cb-vtl-btn:hover { background: var(--bg-secondary, #f3f4f6); }
.cb-vtl-addscene { width: auto; padding: 0 9px; font-size: 11px; font-weight: 600; }
.cb-vtl-addscene:disabled { opacity: .45; cursor: default; }
.cb-vtl-addscene:disabled:hover { background: var(--bg-primary, #fff); }
.cb-vtl-time { font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-primary, #111827); }
.cb-vtl-hint { font-size: 10.5px; color: var(--text-muted, #9ca3af); margin-left: auto; }
.cb-vtl-close { font-size: 15px; line-height: 1; }
.cb-vtl-grid { position: relative; max-height: 168px; overflow-y: auto; overflow-x: hidden; }
.cb-vtl-row { display: flex; align-items: center; height: 24px; }
.cb-vtl-ruler { height: 16px; }
.cb-vtl-label {
    flex: 0 0 112px; width: 112px; font-size: 10.5px; color: var(--text-secondary, #6b7280);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 8px; cursor: pointer;
}
.cb-vtl-label:hover { color: #4f46e5; }
.cb-vtl-lane {
    position: relative; flex: 1; height: 16px; border-radius: 4px;
    background: var(--bg-secondary, #f3f4f6); cursor: crosshair;
}
.cb-vtl-ruler .cb-vtl-lane { background: transparent; cursor: default; }
.cb-vtl-tick { position: absolute; top: 0; font-size: 9px; color: #646B78; transform: translateX(1px); }
/* Timeline audio track — the soundtrack waveform spanning the clip (looped). */
.cb-vtl-wavelane { cursor: default; overflow: hidden; }
.cb-vtl-wave { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity .2s; }
.cb-vtl-wave.is-drawn { opacity: 1; }
.cb-vtl-bar {
    position: absolute; top: 2px; height: 12px; border-radius: 4px; background: #5B53E8;
    cursor: grab; overflow: hidden; display: flex; align-items: center; min-width: 4px;
}
.cb-vtl-bar:active { cursor: grabbing; }
.cb-vtl-bartext { font-size: 8.5px; color: #fff; padding: 0 5px; white-space: nowrap; pointer-events: none; }
.cb-vtl-out { background: #94a3b8; }
.cb-vtl-loop {
    position: absolute; top: 6px; height: 4px; border-radius: 2px; pointer-events: none;
    background: repeating-linear-gradient(90deg, #fbbf24 0 6px, transparent 6px 10px);
}
/* Kinetic-text reveal span — where a type-on / word-by-word text layer reveals
   (mirrors cbRevealAt's window). Emerald, at the bar's bottom edge so it never
   collides with the amber loop stripe (top:6px). */
.cb-vtl-kinetic {
    position: absolute; top: 12px; height: 3px; border-radius: 2px; pointer-events: none;
    background: repeating-linear-gradient(90deg, #10b981 0 4px, transparent 4px 7px);
}
.cb-vtl-handle {
    position: absolute; right: 0; top: 0; width: 7px; height: 100%;
    cursor: ew-resize; background: rgba(255, 255, 255, .35);
}
.cb-vtl-handle-l { right: auto; left: 0; }
.cb-vtl-playhead {
    position: absolute; top: 0; bottom: 0; width: 2px; background: #ef4444;
    border-radius: 1px; pointer-events: none;
}
.cb-vtl-empty { font-size: 11px; color: var(--text-muted, #9ca3af); padding: 8px 2px; }

/* Multi-scene video clips */
.cb-scene-row { display: flex; gap: 5px; align-items: center; margin-bottom: 5px; }
.cb-scene-row input[type="text"] {
    flex: 1; min-width: 0; padding: 5px 7px; font-size: 12px;
    border: 1px solid var(--border-color, #e5e7eb); border-radius: 7px;
}
.cb-scene-row input[type="number"] {
    width: 56px; padding: 5px 5px; font-size: 12px;
    border: 1px solid var(--border-color, #e5e7eb); border-radius: 7px;
}
.cb-scene-tr {
    width: 64px; padding: 5px 4px; font-size: 12px; background: #fff;
    border: 1px solid var(--border-color, #e5e7eb); border-radius: 7px; cursor: pointer;
}
.cb-scene-rm {
    border: none; background: transparent; color: #646B78; font-size: 15px;
    cursor: pointer; padding: 0 3px; line-height: 1;
}
.cb-scene-rm:hover { color: #ef4444; }
.cb-scene-mv {
    border: none; background: transparent; color: #646B78; font-size: 12px;
    cursor: pointer; padding: 0 2px; line-height: 1;
}
.cb-scene-mv:hover { color: var(--text-primary, #111827); }
.cb-scene-mv:disabled { opacity: .3; cursor: default; }
.cb-vtl-scene {
    position: absolute; top: -1px; height: 14px; display: inline-flex; align-items: center;
    justify-content: center; overflow: hidden; cursor: pointer;
    font-size: 8.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
    color: #5B53E8; background: rgba(99, 102, 241, .08);
    border-left: 1px solid rgba(99, 102, 241, .35); border-right: 1px solid rgba(99, 102, 241, .35);
    border-radius: 3px; white-space: nowrap; text-overflow: ellipsis;
}
/* Backlog #9: composed-midpoint scene thumbnail. The dark gradient is layered OVER the
   image in the inline background (backgrounds sit behind text), so the scene name stays
   legible — no ::after scrim needed (the chip's name is a bare text node). */
.cb-vtl-scene--thumb {
    background-size: cover; background-position: center;
    color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .9);
    border-color: rgba(255, 255, 255, .45);
}
/* Scene resize grabber on the chip's right edge — drag to re-time the scene. */
.cb-vtl-scene-handle {
    position: absolute; right: 0; top: 0; bottom: 0; width: 7px;
    cursor: ew-resize; background: rgba(99, 102, 241, .25); border-radius: 0 3px 3px 0;
}
.cb-vtl-scene-handle:hover { background: rgba(99, 102, 241, .6); }
/* Per-scene remove × on the chip's left edge — hover-only (the resize handle owns the right). */
.cb-vtl-scene-rm {
    position: absolute; left: 0; top: 0; bottom: 0; width: 13px;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; line-height: 1; color: #fff; background: rgba(99, 102, 241, .85);
    cursor: pointer; opacity: 0; border-radius: 3px 0 0 3px;
}
.cb-vtl-scene:hover .cb-vtl-scene-rm { opacity: 1; }
.cb-vtl-scene-rm:hover { background: #ef4444; }
.cb-vtl-sep-v {
    position: absolute; top: 16px; bottom: 0; width: 0; pointer-events: none;
    border-left: 1px dashed rgba(99, 102, 241, .45);
}
.cb-vtl-static { background: #d7dbe6; cursor: default; }
.cb-vtl-static .cb-vtl-bartext { color: #6b7280; }

/* Motion-style cards: live mini-previews (a tiny product card animating with
   each style's personality — pure CSS, loops every 3.2s) */
.cb-vstyle-prev {
    position: relative; display: block; width: 100%; height: 42px; margin-bottom: 6px;
    background: #eef0f7; border-radius: 6px; overflow: hidden;
}
.cb-vstyle-prev i { position: absolute; display: block; border-radius: 2px; }
.vsp-img   { left: 5px; top: 6px; width: 26px; height: 30px; background: #c7cde0; }
.vsp-t1    { left: 37px; top: 9px;  width: 34px; height: 6px; background: #9aa3b8; }
.vsp-t2    { left: 37px; top: 20px; width: 24px; height: 6px; background: #b6bdcf; }
.vsp-badge { right: 6px; top: 6px;  width: 13px; height: 13px; border-radius: 999px; background: #e11d48; }
/* subtle: soft fades + slow zoom */
.cb-vsp-subtle .vsp-img   { animation: vspZoom 3.2s ease-in-out infinite; }
.cb-vsp-subtle .vsp-t1    { animation: vspFade 3.2s ease-out infinite .2s both; }
.cb-vsp-subtle .vsp-t2    { animation: vspFade 3.2s ease-out infinite .45s both; }
.cb-vsp-subtle .vsp-badge { animation: vspFade 3.2s ease-out infinite .7s both; }
/* dynamic: fade-up text, badge pop */
.cb-vsp-dynamic .vsp-img   { animation: vspZoom 3.2s linear infinite; }
.cb-vsp-dynamic .vsp-t1    { animation: vspUp 3.2s cubic-bezier(.2,.8,.3,1) infinite .15s both; }
.cb-vsp-dynamic .vsp-t2    { animation: vspUp 3.2s cubic-bezier(.2,.8,.3,1) infinite .35s both; }
.cb-vsp-dynamic .vsp-badge { animation: vspPop 3.2s cubic-bezier(.3,1.6,.4,1) infinite .6s both; }
/* energetic: slide-in text, pulsing badge, end fade */
.cb-vsp-energetic .vsp-img   { animation: vspScaleIn 3.2s cubic-bezier(.2,.8,.3,1) infinite both; }
.cb-vsp-energetic .vsp-t1    { animation: vspSlide 3.2s cubic-bezier(.2,.8,.3,1) infinite .12s both; }
.cb-vsp-energetic .vsp-t2    { animation: vspSlide 3.2s cubic-bezier(.2,.8,.3,1) infinite .28s both; }
.cb-vsp-energetic .vsp-badge { animation: vspPulse 3.2s ease-in-out infinite .5s both; }
/* showcase: slow build, floaty badge */
.cb-vsp-showcase .vsp-img   { animation: vspZoom 3.2s ease-in-out infinite; }
.cb-vsp-showcase .vsp-t1    { animation: vspUp 3.2s ease-out infinite .5s both; }
.cb-vsp-showcase .vsp-t2    { animation: vspUp 3.2s ease-out infinite .8s both; }
.cb-vsp-showcase .vsp-badge { animation: vspFloat 3.2s ease-in-out infinite 1s both; }
@keyframes vspFade  { 0%,8% { opacity: 0; } 22%, 88% { opacity: 1; } 100% { opacity: 1; } }
@keyframes vspUp    { 0%,8% { opacity: 0; transform: translateY(7px); } 26%, 88% { opacity: 1; transform: translateY(0); } 100% { opacity: 1; transform: translateY(0); } }
@keyframes vspSlide { 0%,6% { opacity: 0; transform: translateX(12px); } 22%, 78% { opacity: 1; transform: translateX(0); } 92%, 100% { opacity: 0; transform: translateX(0); } }
@keyframes vspPop   { 0%,16% { opacity: 0; transform: scale(.3); } 30%, 88% { opacity: 1; transform: scale(1); } 100% { opacity: 1; transform: scale(1); } }
@keyframes vspZoom  { 0% { transform: scale(1); } 100% { transform: scale(1.08); } }
@keyframes vspScaleIn { 0% { opacity: 0; transform: scale(.7); } 18%, 80% { opacity: 1; transform: scale(1); } 94%, 100% { opacity: 1; transform: scale(1.02); } }
@keyframes vspPulse { 0%,14% { opacity: 0; transform: scale(.3); } 24% { opacity: 1; transform: scale(1); } 40% { transform: scale(1.18); } 56% { transform: scale(1); } 72% { transform: scale(1.18); } 88%,100% { transform: scale(1); opacity: 1; } }
@keyframes vspFloat { 0%,18% { opacity: 0; } 30% { opacity: 1; transform: translateY(0); } 55% { transform: translateY(-3px); } 80% { transform: translateY(0); } 100% { opacity: 1; } }

/* Timeline: on-screen window bar + loop toggle + ruler scrub affordances */
.cb-vtl-win {
    top: 1px; height: 14px; background: rgba(99, 102, 241, .14);
    border: 1px solid rgba(99, 102, 241, .35);
}
.cb-vtl-win .cb-vtl-bartext { color: #6b7280; }
.cb-vtl-win .cb-vtl-handle { background: rgba(99, 102, 241, .35); }
.cb-vtl-loopbtn.is-on { background: #eef2ff; color: #4f46e5; border-color: #c7d2fe; }
.cb-vtl-tick { pointer-events: none; }
.cb-vtl-ruler .cb-vtl-lane { cursor: crosshair; }

/* Motion tab: one-tap chips, fine-tune fold, remove, timeline row-clear */
.cb-anim-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.cb-anim-chip {
    padding: 4px 9px; font-size: 11.5px; font-weight: 600; border-radius: 999px;
    border: 1px solid var(--border-color, #e5e7eb); background: var(--bg-primary, #fff);
    color: var(--text-secondary, #6b7280); cursor: pointer; line-height: 1.3;
}
.cb-anim-chip:hover { border-color: #c7d2fe; color: #4f46e5; }
.cb-anim-chip.is-on { background: #4f46e5; border-color: #4f46e5; color: #fff; }

/* ── Motion preview GALLERY (Canva/Google-style animated tiles) ───────────────
   Each tile = a mini stage whose token continuously loops the gesture the preset
   applies. Pure CSS keyed by [data-anim]; the motion math (cbAnimState) is
   untouched, so these are preview-only chrome. .cb-anim-tile is a modifier on
   .cb-anim-chip — it inherits the border/hover/is-on wiring and overrides the
   pill shape into a tile. */
.cb-anim-tile {
    display: flex; flex-direction: column; align-items: stretch; gap: 4px;
    padding: 5px 6px 6px; border-radius: 9px; width: 64px; line-height: 1.2;
}
.cb-anim-tile.is-on { background: #eef2ff; border-color: #4f46e5; color: #4338ca; }
.cb-anim-tile.is-on:hover { color: #4338ca; }
.cb-anim-tile-stage {
    position: relative; height: 26px; border-radius: 6px; overflow: hidden;
    background: var(--bg-secondary, #f4f5fb); display: flex; align-items: center; justify-content: center;
}
.cb-anim-tile.is-on .cb-anim-tile-stage { background: #e0e7ff; }
.cb-anim-tile-token {
    width: 22px; height: 9px; border-radius: 3px; background: #818cf8;
    animation-duration: 1.9s; animation-timing-function: ease-in-out; animation-iteration-count: infinite;
    will-change: transform, opacity;
}
.cb-anim-tile.is-on .cb-anim-tile-token { background: #4f46e5; }
.cb-anim-tile-label {
    font-size: 10.5px; font-weight: 600; text-align: center; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
/* "None" tile — a static muted dash, no animation. */
.cb-anim-tile.is-none .cb-anim-tile-token { animation: none; width: 12px; height: 3px; opacity: .45; background: #9ca3af; }

/* Per-preset gesture loops (seamless: 0% == 100%, so no snap). */
.cb-anim-tile[data-anim="fadein"]     .cb-anim-tile-token { animation-name: cbT-fadein; }
.cb-anim-tile[data-anim="fadeup"]     .cb-anim-tile-token { animation-name: cbT-fadeup; }
.cb-anim-tile[data-anim="slideleft"]  .cb-anim-tile-token { animation-name: cbT-slideleft; }
.cb-anim-tile[data-anim="slideright"] .cb-anim-tile-token { animation-name: cbT-slideright; }
.cb-anim-tile[data-anim="scalein"]    .cb-anim-tile-token { animation-name: cbT-scalein; }
.cb-anim-tile[data-anim="pop"]        .cb-anim-tile-token { animation-name: cbT-pop; }
.cb-anim-tile[data-anim="zoomin"]     .cb-anim-tile-token { animation-name: cbT-zoomin; }
.cb-anim-tile[data-anim="dropin"]     .cb-anim-tile-token { animation-name: cbT-dropin; }
.cb-anim-tile[data-anim="kenburns"]   .cb-anim-tile-token { animation-name: cbT-kenburns; animation-duration: 3.2s; }
.cb-anim-tile[data-anim="fadeout"]       .cb-anim-tile-token { animation-name: cbT-fadeout; }
.cb-anim-tile[data-anim="slideoutleft"]  .cb-anim-tile-token { animation-name: cbT-slideoutleft; }
.cb-anim-tile[data-anim="slideoutright"] .cb-anim-tile-token { animation-name: cbT-slideoutright; }
.cb-anim-tile[data-anim="scaleout"]      .cb-anim-tile-token { animation-name: cbT-scaleout; }
.cb-anim-tile[data-anim="zoomout"]       .cb-anim-tile-token { animation-name: cbT-zoomout; }
.cb-anim-tile[data-anim="riseout"]       .cb-anim-tile-token { animation-name: cbT-riseout; }
.cb-anim-tile[data-anim="pulse"]   .cb-anim-tile-token { animation-name: cbT-pulse; }
.cb-anim-tile[data-anim="float"]   .cb-anim-tile-token { animation-name: cbT-float; animation-duration: 2.6s; }
.cb-anim-tile[data-anim="breathe"] .cb-anim-tile-token { animation-name: cbT-breathe; animation-duration: 3s; }
.cb-anim-tile[data-anim="sway"]    .cb-anim-tile-token { animation-name: cbT-sway; animation-duration: 2.6s; }
.cb-anim-tile[data-anim="typewriter"] .cb-anim-tile-token { animation-name: cbT-typewriter; animation-duration: 2.1s; transform-origin: left center; }

@keyframes cbT-fadein     { 0%, 100% { opacity: .2; } 45% { opacity: 1; } }
@keyframes cbT-fadeup     { 0%, 100% { transform: translateY(7px);  opacity: .2; } 45% { transform: translateY(0); opacity: 1; } }
@keyframes cbT-slideleft  { 0%, 100% { transform: translateX(14px); opacity: .2; } 45% { transform: translateX(0); opacity: 1; } }
@keyframes cbT-slideright { 0%, 100% { transform: translateX(-14px); opacity: .2; } 45% { transform: translateX(0); opacity: 1; } }
@keyframes cbT-scalein    { 0%, 100% { transform: scale(.5); opacity: .2; } 45% { transform: scale(1); opacity: 1; } }
@keyframes cbT-pop        { 0%, 100% { transform: scale(.5); opacity: .2; } 38% { transform: scale(1.14); opacity: 1; } 52% { transform: scale(1); } }
@keyframes cbT-zoomin     { 0%, 100% { transform: scale(1.45); opacity: .2; } 45% { transform: scale(1); opacity: 1; } }
@keyframes cbT-dropin     { 0%, 100% { transform: translateY(-12px); opacity: .2; } 45% { transform: translateY(0); opacity: 1; } }
@keyframes cbT-kenburns   { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }
@keyframes cbT-fadeout       { 0%, 100% { opacity: 1; } 50% { opacity: .15; } }
@keyframes cbT-slideoutleft  { 0%, 100% { transform: translateX(0); opacity: 1; } 50% { transform: translateX(-15px); opacity: .15; } }
@keyframes cbT-slideoutright { 0%, 100% { transform: translateX(0); opacity: 1; } 50% { transform: translateX(15px); opacity: .15; } }
@keyframes cbT-scaleout      { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.5); opacity: .15; } }
@keyframes cbT-zoomout       { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.5); opacity: .15; } }
@keyframes cbT-riseout       { 0%, 100% { transform: translateY(0); opacity: 1; } 50% { transform: translateY(-11px); opacity: .15; } }
@keyframes cbT-pulse   { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }
@keyframes cbT-float   { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes cbT-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@keyframes cbT-sway    { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(6px); } }
/* Typewriter: the bar reveals left→right (clip-path, no layout shift), holds,
   then fades so the loop reset is masked at low opacity. */
@keyframes cbT-typewriter {
    0%   { clip-path: inset(0 100% 0 0); opacity: .4; }
    12%  { opacity: 1; }
    60%  { clip-path: inset(0 0 0 0); opacity: 1; }
    88%  { clip-path: inset(0 0 0 0); opacity: 1; }
    100% { clip-path: inset(0 0 0 0); opacity: 0; }
}

/* Accessibility — freeze the preview loops at rest for reduced-motion users. */
@media (prefers-reduced-motion: reduce) {
    .cb-anim-tile-token { animation: none !important; }
}

/* One-line plain-language motion recap (Enter · reveal · loop · Exit) — reads the
   whole layer's behaviour at a glance above the chips. */
.cb-anim-summary {
    font-size: 11.5px; font-weight: 600; color: #4338ca;
    background: #eef2ff; border: 1px solid #e0e7ff; border-radius: 7px;
    padding: 5px 9px; margin: 2px 0 10px; line-height: 1.35;
}
.cb-anim-summary.is-empty {
    color: var(--text-muted, #9ca3af); background: var(--bg-secondary, #f4f5fb);
    border-color: var(--border-color, #e5e7eb); font-weight: 500;
}

/* Speed segmented control (Slow / Normal / Fast) under the Enter chips. */
.cb-anim-speedgrp { margin-top: 2px; }
.cb-anim-speed {
    display: inline-flex; border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px; overflow: hidden; width: max-content;
}
.cb-anim-speedbtn {
    border: none; border-right: 1px solid var(--border-color, #e5e7eb);
    background: #fff; color: var(--text-secondary, #6b7280);
    font-size: 11.5px; font-weight: 600; padding: 5px 14px; cursor: pointer;
}
.cb-anim-speedbtn:last-child { border-right: none; }
.cb-anim-speedbtn:hover { background: var(--bg-secondary, #f4f5fb); }
.cb-anim-speedbtn.is-on { background: #eef2ff; color: #4338ca; }

.cb-anim-fine { margin-top: 10px; }
.cb-anim-fine > summary {
    font-size: 11px; font-weight: 700; color: var(--text-secondary, #6b7280);
    cursor: pointer; user-select: none; padding: 3px 0;
}
.cb-anim-fine > summary:hover { color: #4f46e5; }
.cb-anim-sliderrow { display: flex; align-items: center; gap: 7px; margin-top: 7px; }
.cb-anim-sliderrow > label { flex: 0 0 64px; font-size: 11px; color: var(--text-secondary, #6b7280); }
.cb-anim-sliderrow input[type="range"] { flex: 1; min-width: 0; accent-color: #5B53E8; }
.cb-anim-sliderval { flex: 0 0 34px; font-size: 11px; font-variant-numeric: tabular-nums; color: var(--text-primary, #111827); text-align: right; }
.cb-anim-sliderrow .prop-select { flex: 1; }
.cb-anim-winwrap { display: flex; align-items: center; gap: 5px; flex: 1; }
.cb-anim-winwrap input { width: 58px; padding: 4px 5px; font-size: 11.5px; border: 1px solid var(--border-color, #e5e7eb); border-radius: 6px; }
.cb-anim-winarrow { color: var(--text-muted, #9ca3af); font-size: 11px; }
.cb-anim-foot { display: flex; gap: 6px; margin-top: 10px; }
.cb-anim-foot .btn { flex: 1; }
.cb-anim-remove { color: #b91c1c; }
.cb-anim-remove:hover:not(:disabled) { background: #fef2f2; border-color: #fecaca; }
.cb-anim-remove:disabled { opacity: .45; cursor: default; }
.cb-vtl-label { position: relative; padding-right: 16px; }
.cb-vtl-rowrm {
    position: absolute; right: 0; top: 50%; transform: translateY(-50%);
    border: none; background: transparent; color: #646B78; font-size: 13px;
    line-height: 1; cursor: pointer; padding: 1px 3px; opacity: 0;
}
.cb-vtl-row:hover .cb-vtl-rowrm { opacity: 1; }
.cb-vtl-rowrm:hover { color: #ef4444; }

/* Floating video pill (top-center over the template canvas) + first-open coach */
.cb-vpill {
    position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 590;
    display: flex; align-items: center; gap: 7px;
    background: var(--bg-primary, #fff); border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 999px; padding: 5px 9px; box-shadow: 0 6px 18px rgba(15, 23, 42, .12);
}
.cb-vpill-btn {
    border: 1px solid var(--border-color, #e5e7eb); background: var(--bg-primary, #fff);
    border-radius: 999px; min-width: 26px; height: 24px; padding: 0 8px;
    font-size: 11px; font-weight: 700; cursor: pointer; color: var(--text-primary, #111827);
    display: inline-flex; align-items: center; justify-content: center;
}
.cb-vpill-btn:hover { background: var(--bg-secondary, #f3f4f6); }
.cb-vpill-mp4 { color: #4f46e5; border-color: #c7d2fe; }
.cb-vpill-mp4:hover { background: #eef2ff; }
.cb-vpill-time { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-secondary, #6b7280); }
.cb-vcoach {
    position: fixed; bottom: 18px; left: 18px; z-index: 590; width: 290px;
    background: var(--bg-primary, #fff); border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 12px; padding: 12px 14px; box-shadow: 0 12px 32px rgba(15, 23, 42, .16);
}
.cb-vcoach-title { font-size: 12.5px; font-weight: 800; color: var(--text-primary, #111827); margin-bottom: 6px; }
.cb-vcoach ul { margin: 0 0 10px; padding-left: 16px; }
.cb-vcoach li { font-size: 11.5px; color: var(--text-secondary, #6b7280); line-height: 1.45; margin-bottom: 4px; }

/* Soundtrack row (clip settings) */
.cb-snd-name { flex: 1; min-width: 0; font-size: 11.5px; color: var(--text-primary, #111827); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-snd-addrow { display: flex; gap: 6px; }
.cb-snd-addrow .btn { flex: 1; }
/* Soundtrack LIBRARY — the project's own audio, listed so a track can be reused instead of
   re-uploaded. Capped and scrollable: a project that has collected twenty tracks must not push
   the volume slider and the waveform off the panel. */
.cb-snd-lib { margin-top: 6px; max-height: 168px; overflow-y: auto; border: 1px solid var(--border, #e5e7eb); border-radius: 6px; }
.cb-snd-libhead { padding: 5px 7px 3px; font-size: 10px; font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; color: var(--text-secondary, #6b7280); background: var(--bg-subtle, #fafafa); }
.cb-snd-libhead + .cb-snd-libitem { border-top: 0; }
.cb-snd-libitem { display: flex; align-items: center; gap: 6px; padding: 5px 7px; cursor: pointer; }
.cb-snd-libitem + .cb-snd-libitem { border-top: 1px solid var(--border, #e5e7eb); }
.cb-snd-libitem:hover { background: var(--bg-hover, #f3f4f6); }
.cb-snd-play { flex: 0 0 auto; width: 22px; height: 22px; line-height: 1; padding: 0; cursor: pointer;
    border: 1px solid var(--border, #e5e7eb); border-radius: 50%; background: var(--bg-elevated, #fff);
    color: var(--text-primary, #111827); font-size: 10px; }
.cb-snd-play:hover { border-color: var(--accent, #5B53E8); color: var(--accent, #5B53E8); }
/* Soundtrack PICKER (2026-10-31): Royalty-free (curated CC0) | Your uploads (this project). */
.cb-snd-picker { display: flex; flex-direction: column; gap: 6px; }
.cb-snd-tabs { display: flex; gap: 4px; padding: 2px; border-radius: 8px; background: var(--bg-secondary, #f4f5fb); }
.cb-snd-tab { flex: 1; padding: 5px 6px; border: 0; border-radius: 6px; background: transparent; cursor: pointer;
    font-size: 11.5px; font-weight: 600; color: var(--text-secondary, #6b7280); }
.cb-snd-tab.is-active { background: var(--bg-elevated, #fff); color: var(--text-primary, #111827); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.cb-snd-moods { display: flex; flex-wrap: wrap; gap: 4px; }
.cb-snd-mood { padding: 3px 8px; border: 1px solid var(--border, #e5e7eb); border-radius: 999px; background: var(--bg-elevated, #fff);
    font-size: 10.5px; color: var(--text-secondary, #6b7280); cursor: pointer; }
.cb-snd-mood.is-active { border-color: var(--accent, #5B53E8); color: var(--accent, #5B53E8); background: var(--accent-soft, #f1f0fc); }
.cb-snd-body .cb-snd-lib { max-height: 236px; }
.cb-snd-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cb-snd-sub { font-size: 10.5px; color: var(--text-secondary, #6b7280); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-snd-use { flex: 0 0 auto; padding: 3px 8px; border: 1px solid var(--accent, #5B53E8); border-radius: 6px; background: transparent;
    color: var(--accent, #5B53E8); font-size: 10.5px; font-weight: 600; cursor: pointer; }
.cb-snd-use:hover { background: var(--accent, #5B53E8); color: #fff; }
.cb-snd-rm { flex: 0 0 auto; width: 20px; height: 20px; border: 0; background: transparent; color: var(--text-secondary, #6b7280);
    font-size: 15px; line-height: 1; cursor: pointer; }
.cb-snd-rm:hover { color: #dc2626; }
.cb-snd-license { font-size: 10.5px; color: var(--text-secondary, #6b7280); line-height: 1.4; }
.cb-snd-license a { color: inherit; text-decoration: underline; }
.cb-snd-loop { display: flex; align-items: center; gap: 6px; margin: 4px 0; font-size: 11.5px; color: var(--text-primary, #111827); cursor: pointer; }
.cb-snd-loop input { accent-color: var(--accent, #5B53E8); }
.cb-snd-hint { margin-left: auto; font-size: 10.5px; color: var(--text-secondary, #6b7280); }
/* Soundtrack waveform — full-width strip. Collapsed (height 0) until successfully
   drawn, so a CORS/decode failure leaves NO empty box. width:100% still gives the
   async paint a real clientWidth to measure while collapsed. */
.cb-snd-wave { display: block; width: 100%; height: 0; margin: 0; border-radius: 6px; background: var(--bg-secondary, #f4f5fb); opacity: 0; transition: opacity .2s; }
.cb-snd-wave.is-drawn { height: 34px; margin: 6px 0 2px; opacity: 1; }

/* Message-rotation dialog */
.cb-rot-ta {
    width: 100%; margin-top: 8px; padding: 9px 11px; resize: vertical;
    border: 1px solid var(--border-subtle, #e5e7eb); border-radius: 8px;
    font-size: 13px; font-family: inherit; line-height: 1.5;
    color: var(--text-primary, #111827); background: #fff;
}
.cb-rot-ta:focus { outline: none; border-color: #5B53E8; box-shadow: 0 0 0 3px rgba(99, 102, 241, .12); }

/* Template health — feed-check report rows */
.cb-fc-list { margin: 10px 0 6px; }
.cb-fc-row { display: flex; gap: 8px; align-items: flex-start; padding: 7px 0; border-bottom: 1px solid var(--border-subtle, #e5e7eb); }
.cb-fc-row:last-child { border-bottom: none; }
.cb-fc-ic { width: 16px; flex: none; font-size: 12px; line-height: 1.4; text-align: center; }
.cb-fc-txt { min-width: 0; }
.cb-fc-name { font-size: 12px; font-weight: 600; color: var(--text-primary, #111827); }
.cb-fc-sub { font-size: 11.5px; color: var(--text-secondary, #6b7280); line-height: 1.4; }
.cb-fc-ok   { color: #059669; }
.cb-fc-info { color: #6b7280; }
.cb-fc-warn { color: #d97706; }
.cb-fc-bad  { color: #dc2626; }
.cb-fc-allok { margin: 10px 0 2px; font-size: 12.5px; font-weight: 600; color: #059669; }
.cb-fc-link {
    background: none; border: none; padding: 0 1px; cursor: pointer;
    font-size: 11.5px; color: #5B53E8; text-decoration: underline;
}
.cb-fc-link:hover { color: #4f46e5; }

/* Video SCENE conditions — the per-scene "when does this beat play?" builder. Indented under
   its scene row so it reads as belonging to that scene rather than to the Scenes list. The
   builder's own narrow-panel sizing comes from .cb-cond-section, which the wrapper also
   carries (see cbRenderSceneConditions). */
.cb-scene-conds { margin: -2px 0 10px 0; padding-left: 10px; border-left: 2px solid var(--border, #e6e6ef); }
.cb-scene-conds .cb-binding-hint { margin-top: 4px; }

/* ============================================================================
 * FRAMES — the slide filmstrip for video templates (bottom dock, video only).
 * Cards read left-to-right in play order, so the strip IS the storyboard: the
 * thumbnail answers "what is on this slide", the row under it answers "how long
 * and how does it arrive".
 * ========================================================================== */
.cb-frm-pane {
    /* Card width is driven from the pane's own height by cbFrmFitCards — the strip has to be
       right at every dock height, not at the one it was designed against. */
    --frm-w: 104px;
    padding: 0 10px 10px; overflow: hidden;
    flex-direction: column; min-height: 0;
}
/* The column layout applies only when this pane is the ACTIVE one. Setting `display: flex`
   on .cb-frm-pane itself beat `.cb-bdock-pane { display: none }` on source order alone, so a
   hidden Frames pane still took its full height and stacked under the Timeline — a 1500x1050
   window ended up with a 666px dock. Needs the extra class to outrank `.cb-bdock-pane.active`. */
.cb-bdock-pane.cb-frm-pane.active { display: flex; }

/* ── THE HEADER ────────────────────────────────────────────────────────────
   One bar: the grammar that plays the whole slideshow on the left, what it does in the
   middle, the frame count and running time on the right. STICKY, because scrolling the
   storyboard must never scroll away the control that governs it. */
.cb-frm-head {
    position: sticky; top: 0; z-index: 3; flex: 0 0 auto;
    display: flex; align-items: center; gap: 12px;
    margin: 0 -10px 9px; padding: 8px 12px;
    background: var(--bg-primary, #fff);
    border-bottom: 1px solid var(--border-subtle, #eef0f4);
}
.cb-frm-fx { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.cb-frm-fx__lbl {
    font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    color: #5b4ec4; background: #f1efff; border-radius: 5px; padding: 3px 7px;
}
.cb-frm-fx__sel {
    font-size: 12px; font-weight: 600; color: #1f2a3d;
    padding: 5px 26px 5px 9px; min-width: 148px;
    border: 1px solid var(--border-color, #d7dce6); border-radius: 7px; background: #fff;
    /* Native select arrows differ per platform and one of them is 22px of grey gradient;
       draw our own so the control matches the app's inputs on every OS. */
    -webkit-appearance: none; appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236b7280' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 9px center;
    cursor: pointer;
}
.cb-frm-fx__sel:hover { border-color: #b9c2d4; }
.cb-frm-fx__sel:focus-visible { outline: 2px solid #5B53E8; outline-offset: 1px; border-color: #5B53E8; }

/* The hint is the first thing to give up room when the dock narrows — it carries its full
   text as a title so a truncated sentence is still recoverable. */
.cb-frm-hint {
    flex: 1 1 auto; min-width: 0;
    font-size: 11.5px; color: var(--text-muted, #8a93a6);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* While the all-frames tile is selected the hint is telling you what that MEANS, not
   describing the effect — so it reads as a note rather than as caption text. */
.cb-frm-hint.is-note { color: #4A43D6; font-weight: 600; }

/* The preview-product picker, borrowed into the strip header. It is built for a 320px side
   panel and sizes its own children, so the cap has to be enforced on the DESCENDANTS too —
   capping only the wrapper let a long product title push the frame count off the bar. */
.cb-frm-prev {
    flex: 0 1 260px; min-width: 0; max-width: 260px; overflow: hidden;
    display: flex; align-items: center; gap: 6px; margin: 0 0 0 auto;
}
.cb-frm-prev * { min-width: 0; max-width: 100%; }
.cb-frm-prev select, .cb-frm-prev input { font-size: 12px; }
/* The title is the part that has to give: one line, ellipsed, never wrapping the bar taller. */
.cb-frm-prev [class*="title"], .cb-frm-prev [class*="name"], .cb-frm-prev span {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cb-frm-prev img { flex: 0 0 auto; width: 26px; height: 26px; object-fit: contain; border-radius: 5px; }
/* With the picker present the stats sit after it, so the auto-margin moves to the picker. */
.cb-frm-head > .cb-frm-stats { margin-left: 0; }

.cb-frm-stats {
    flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px;
    font-size: 11.5px; color: var(--text-secondary, #6b7280); white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.cb-frm-stats b { font-weight: 700; color: var(--text-primary, #111827); }
.cb-frm-dot { width: 3px; height: 3px; border-radius: 50%; background: #c7cdd9; margin: 0 3px; }
.cb-frm-total { font-weight: 700; }

/* ── THE STRIP ─────────────────────────────────────────────────────────────
   Scrolls sideways only. A storyboard read left-to-right must never also scroll down —
   two scrollbars is how the cards ended up clipped below their thumbnails. */
.cb-frm-strip {
    flex: 1 1 auto; min-height: 0;
    display: flex; align-items: flex-start; gap: 8px;
    overflow-x: auto; overflow-y: hidden;
    padding-bottom: 4px;
    scrollbar-width: thin;
}
.cb-frm-strip::-webkit-scrollbar { height: 8px; }
.cb-frm-strip::-webkit-scrollbar-thumb { background: #d3d9e4; border-radius: 4px; }
.cb-frm-strip::-webkit-scrollbar-thumb:hover { background: #bcc4d3; }
.cb-frm-strip::-webkit-scrollbar-track { background: transparent; }

.cb-frm-card {
    flex: 0 0 auto; width: var(--frm-w); height: var(--frm-h);
    display: flex; flex-direction: column; gap: 5px;
    padding: 6px; border-radius: 10px; overflow: hidden;
    container: frmcard / inline-size;
    position: relative;   /* positioning context for the .is-pinned badge */
    border: 1px solid var(--border-color, #e5e7eb); background: #fff;
    box-shadow: 0 1px 2px rgba(16,24,40,.04);
    transition: border-color .12s, box-shadow .12s, transform .12s;
}
.cb-frm-card:hover { border-color: #c8cfdb; box-shadow: 0 4px 12px rgba(16,24,40,.09); }
/* This frame is CONDITIONED OUT for the product being previewed — the renderer leaves it out of
   that product's clip. Dimmed rather than hidden, and never styled as an error: the frame is
   correct, it simply does not apply to this one product. The thumbnail keeps full opacity so the
   card is still recognisable and editable — the strip IS the document. */
.cb-frm-card.is-condoff { background: #fafafb; border-style: dashed; }
.cb-frm-card.is-condoff .cb-frm-name,
.cb-frm-card.is-condoff .cb-frm-nameIn,
.cb-frm-card.is-condoff .cb-frm-row { opacity: .55; }
.cb-frm-card.is-condoff .cb-frm-thumb { opacity: .62; filter: saturate(.55); }
.cb-frm-card.is-condoff:hover .cb-frm-thumb { opacity: 1; filter: none; }
/* The selected frame stays unmistakably selected even when it is conditioned out. */
.cb-frm-card.is-condoff.is-on { border-style: solid; }
/* PAUSED frame (right-click → Pause frame): kept in the template, left out of the video for every
   product. Greyed + a "Paused" badge over the thumbnail; hover restores it so it stays editable. */
.cb-frm-card.is-paused { background: #f4f4f6; border-style: dashed; border-color: #c9ccd4; }
.cb-frm-card.is-paused .cb-frm-thumb { opacity: .45; filter: grayscale(1); }
.cb-frm-card.is-paused .cb-frm-name,
.cb-frm-card.is-paused .cb-frm-nameIn,
.cb-frm-card.is-paused .cb-frm-row { opacity: .55; }
.cb-frm-card.is-paused:hover .cb-frm-thumb { opacity: .8; filter: grayscale(.4); }
.cb-frm-card.is-paused.is-on { border-style: solid; }
.cb-frm-paused {
    position: absolute; top: 6px; left: 50%; transform: translateX(-50%); z-index: 2;
    font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    color: #fff; background: #4b5563; border-radius: 999px; padding: 2px 8px; pointer-events: auto;
    box-shadow: 0 2px 6px rgba(15,23,42,.2);
}
.cb-frm-pausedn { color: #6b7280; font-weight: 600; }
/* The focused frame is what the canvas is showing, so it gets the strongest state. */
.cb-frm-card.is-on {
    border-color: #5B53E8; box-shadow: 0 0 0 3px rgba(91,83,232,.16);
}

/* SQUARE. A strip read left-to-right spends its budget on width; a 4:5 thumb spent it on
   height, the axis that is scarce, and pushed the controls out of the pane.
   The tile is a light ground so a white artboard still reads as a page on it. */
.cb-frm-thumb {
    position: relative; display: block; width: 100%; flex: 0 0 auto; aspect-ratio: 1 / 1;
    border: 1px solid #eef0f4; padding: 0; border-radius: 7px; overflow: hidden;
    background: #f4f5f8 center/contain no-repeat; cursor: pointer;
}
/* The tile that SELECTS a frame is the dock's primary keyboard target — it also carries the
   Alt+Arrow reorder gesture — yet it was the only control here with no focus treatment, while the
   duration box and the action buttons both had one. Same indigo as .cb-frm-act, so focus reads as
   one language across the dock. */
.cb-frm-thumb:focus-visible,
.cb-frm-card.cb-frm-all:focus-visible,
.cb-frm-card.cb-frm-add:focus-visible { outline: 2px solid #5B53E8; outline-offset: 2px; }
/* A 9:16 artboard letterboxed into a square tile is mostly white on light grey, and without
   an edge the page and the ground read as one shape. drop-shadow follows the CONTAINED image's
   actual box, which a border on the <img> would not. */
.cb-frm-thumb img {
    width: 100%; height: 100%; object-fit: contain; display: block;
    filter: drop-shadow(0 0 0.5px rgba(17,24,39,.28)) drop-shadow(0 1px 2px rgba(17,24,39,.10));
}
.cb-frm-noimg { display: grid; place-items: center; width: 100%; height: 100%; color: #646B78; font-size: 20px; font-weight: 700; }
.cb-frm-idx {
    position: absolute; left: 5px; top: 5px;
    min-width: 16px; height: 16px; padding: 0 4px; border-radius: 5px;
    background: rgba(255,255,255,.94); border: 1px solid #e5e7eb; color: #6b7280;
    font-size: 10px; font-weight: 700; line-height: 15px; text-align: center;
}
.cb-frm-card.is-on .cb-frm-idx { background: #5B53E8; border-color: #5B53E8; color: #fff; }

/* Rename in place: the field is invisible until you go near it, so six cards read as six
   titles rather than six form controls. */
/* The frame's TITLE. Reads as a title, edits in place — a field that looks like a form
   control on six cards turns a storyboard into a spreadsheet. */
.cb-frm-nameIn {
    width: 100%; min-width: 0; flex: 0 0 auto; height: 26px;
    border: 1px solid transparent; border-radius: 6px; background: transparent;
    color: var(--text-primary, #1f2937); font-size: 12.5px; font-weight: 600;
    padding: 0 6px; text-overflow: ellipsis;
}
.cb-frm-nameIn:hover { background: #f2f4f8; }
.cb-frm-nameIn:focus { background: #fff; border-color: #5B53E8; outline: none; box-shadow: 0 0 0 3px rgba(91,83,232,.14); }

.cb-frm-row {
    display: flex; align-items: center; gap: 6px; row-gap: 4px;
    min-width: 0; flex: 0 0 auto; flex-wrap: wrap;
}

/* DURATION as one labelled control: the clock says what the number means and the unit sits
   inside the field, instead of a naked spinner with a stray "s" beside it. */
.cb-frm-durbox {
    display: inline-flex; align-items: center; gap: 3px; height: 28px; padding: 0 6px;
    border: 1px solid var(--border-color, #e5e7eb); border-radius: 7px; background: #fff;
    cursor: text; flex: 0 1 auto; min-width: 0; overflow: hidden;
}
/* On a narrow card the clock is the first thing to go: the number and its unit are the
   information, the icon is only a label for them. A container query, because what is narrow is
   the CARD — the viewport can be any size while the dock is short and the cards are small. */
@container frmcard (max-width: 150px) { .cb-frm-durico { display: none; } }
.cb-frm-durbox:hover { border-color: #c8cfdb; }
.cb-frm-durbox:focus-within { border-color: #5B53E8; box-shadow: 0 0 0 3px rgba(91,83,232,.14); }
.cb-frm-durico { display: inline-flex; color: #646B78; }
.cb-frm-durbox:focus-within .cb-frm-durico { color: #5B53E8; }
.cb-frm-dur {
    width: 34px; min-width: 20px; flex: 0 1 auto; border: 0; background: transparent; padding: 0;
    color: var(--text-primary, #1f2937); font-size: 13px; font-weight: 600;
    font-variant-numeric: tabular-nums; text-align: right;
}
.cb-frm-dur:focus { outline: none; }
/* The spinner arrows are 16px of chrome on a 34px field and fight the unit for space. */
.cb-frm-dur::-webkit-outer-spin-button, .cb-frm-dur::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cb-frm-dur { -moz-appearance: textfield; }
.cb-frm-durs { font-size: 11.5px; font-weight: 600; color: var(--text-muted, #9ca3af); }

/* ACTIONS: real buttons with drawn icons. The old glyphs (← → ⧉ ×) were 20px wide at 11px and
   read as decoration; delete gave no sign it was destructive until after it had run. */
.cb-frm-acts { display: flex; gap: 2px; flex: 0 0 auto; margin-left: auto; }
/* Wrapped onto its own line the auto-margin would shove the buttons to the far edge; on a
   narrow card that reads as them escaping rather than as alignment. */
.cb-frm-row > .cb-frm-acts:only-child, .cb-frm-card.is-narrow .cb-frm-acts { margin-left: 0; }
.cb-frm-act {
    width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
    border: 0; border-radius: 7px; background: transparent;
    color: #646B78; cursor: pointer; padding: 0;
    transition: background .12s, color .12s;
}
.cb-frm-act svg { width: 15px; height: 15px; display: block; }
.cb-frm-act:hover:not(:disabled) { background: #eeedfc; color: #5B53E8; }
.cb-frm-act.is-danger:hover:not(:disabled) { background: #fdecec; color: #d64545; }
.cb-frm-act:focus-visible { outline: 2px solid #5B53E8; outline-offset: 1px; }
.cb-frm-act:disabled { opacity: .28; cursor: default; }

/* "All frames" and "Add frame" are tiles too — same box, same size, centred content. */
.cb-frm-all, .cb-frm-add {
    align-items: center; justify-content: center; text-align: center;
    cursor: pointer; color: var(--text-secondary, #6b7280);
}
.cb-frm-all.is-on { background: #f7f7fe; }
.cb-frm-add { border-style: dashed; border-color: #d5dbe6; box-shadow: none; background: #fcfcfd; }
.cb-frm-add:hover { border-color: #5B53E8; background: #f7f7fe; color: #5B53E8; }
/* At the six-frame cap the Add tile is disabled. Say so on the tile — a greyed control whose
   reason lives only in a tooltip reads as broken to anyone who does not hover it. */
.cb-frm-add:disabled {
    cursor: default; opacity: 1;
    background: #fafbfc; border-color: #e8ebf0; color: #b6bdc9; box-shadow: none;
}
.cb-frm-add:disabled:hover { border-color: #e8ebf0; background: #fafbfc; color: #b6bdc9; }
.cb-frm-add:disabled .cb-frm-plus { color: #d6dae2; }
.cb-frm-plus { font-size: 26px; line-height: 1; color: #646B78; }
.cb-frm-allico { display: inline-flex; color: #646B78; margin-bottom: 2px; }
.cb-frm-allico svg { width: 26px; height: 26px; }
.cb-frm-all.is-on .cb-frm-allico { color: #5B53E8; }
.cb-frm-all .cb-frm-name, .cb-frm-add .cb-frm-name { padding: 0 6px; line-height: 1.25; }
.cb-frm-all .cb-frm-sub, .cb-frm-add .cb-frm-sub { padding: 0 6px; line-height: 1.3; }
.cb-frm-add:hover .cb-frm-plus { color: #5B53E8; }
.cb-frm-name { font-size: 11.5px; font-weight: 600; color: var(--text-primary, #1f2937); }
.cb-frm-sub  { font-size: 10px; color: var(--text-muted, #9ca3af); }

/* COMPACT: when the dock is deliberately short, show LESS rather than part of everything.
   The name field and the conditions label go; the thumbnail and the duration stay, because
   those are what the strip is for. */
.cb-frm-pane.is-compact .cb-frm-nameIn,
.cb-frm-pane.is-compact .cb-frm-cond { display: none; }
.cb-frm-pane.is-compact .cb-frm-card { gap: 5px; padding: 6px; }
/* Compact drops rows, it does not shrink what is left — a half-size control is harder to hit
   than a missing one is to miss.
   The actions take a FULL LINE rather than sharing one with the duration. Relying on flex-wrap
   to sort it out was 1px of arithmetic away from failing, and it did: at a 146px card the row
   fitted but the buttons were pushed 9px past the card edge. flex-basis:100% wraps them by
   construction, at every width, with no sum to get wrong. */
.cb-frm-pane.is-compact .cb-frm-acts {
    flex: 1 0 100%; margin-left: 0; justify-content: flex-end;
}
/* At the card's own floor (64px) two 26px buttons plus their gap need 54px of a 50px line.
   22px still gives a real target and fits — a control that is 4px clipped reads as broken. */
@container frmcard (max-width: 96px) {
    .cb-frm-act { width: 22px; height: 22px; }
    .cb-frm-act svg { width: 13px; height: 13px; }
}
.cb-frm-pane.is-compact .cb-frm-name { font-size: 10px; }
.cb-frm-pane.is-compact .cb-frm-sub { display: none; }

/* DRAG TO REORDER. The old indicator was a 3px shadow on the edge of whichever card the
   pointer was over — you had to know a shadow on the right meant "after this one". A card-sized
   SLOT opens where the frame will land instead, and the cards slide aside for it, so the strip
   shows the result rather than encoding it. */
.cb-frm-card[draggable="true"] { cursor: grab; }
.cb-frm-card.is-dragging {
    opacity: .4; cursor: grabbing; transform: scale(.96) rotate(-1.2deg);
    box-shadow: 0 10px 24px rgba(16,24,40,.16);
}
.cb-frm-slot {
    flex: 0 0 auto; width: 0; height: var(--frm-h); align-self: flex-start;
    border-radius: 10px; border: 2px dashed #5B53E8; background: #f5f4fe;
    opacity: 0; overflow: hidden; pointer-events: none;
    transition: width .17s cubic-bezier(.2,.8,.25,1), opacity .12s linear, margin .17s cubic-bezier(.2,.8,.25,1);
    margin: 0 -4px;                       /* absorbs the strip gap while closed */
}
.cb-frm-slot.is-in { width: var(--frm-w); opacity: 1; margin: 0; }
/* Everything gets out of the way smoothly while a drag is live. */
.cb-frm-strip.is-dragging .cb-frm-card { transition: transform .17s cubic-bezier(.2,.8,.25,1), border-color .12s, box-shadow .12s; }

/* Frame conditions: the card states whether a frame is conditional, because one that
   quietly disappears for most products is otherwise indistinguishable from a broken one. */
/* WHEN this frame plays, named. "1 rule" made you open a popover to find out which — for
   every frame, every time. `is-auto` marks a rule derived from what the frame's layers read,
   which is the common case and should not look like something you configured. */
.cb-frm-cond {
    width: 100%; text-align: left; flex: 0 0 auto; height: 26px; line-height: 24px;
    border: 1px solid transparent; border-radius: 7px; background: #f2f4f8;
    color: var(--text-muted, #8b93a3); font-size: 11.5px; padding: 0 8px; cursor: pointer;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cb-frm-cond:hover { background: #e8ebf2; color: var(--text-secondary, #6b7280); }
.cb-frm-cond.is-set { background: #eeedfc; border-color: #ddd9fb; color: #4A43D6; font-weight: 600; }
.cb-frm-cond.is-set.is-auto { background: #f4f6fb; border-color: #e2e7f2; color: #5f6b85; font-weight: 500; }
.cb-frm-cond.is-set.is-auto:hover { background: #eeedfc; border-color: #ddd9fb; color: #4A43D6; }

.cb-frm-condpop {
    position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 40;
    max-height: 62vh; overflow: auto;
    border: 1px solid #2b3550; border-radius: 10px; background: #141b2c;
    box-shadow: 0 18px 44px rgba(0,0,0,.5); padding: 12px 14px 14px;
}
/* THE MATCH-COUNT LINE INSIDE THE FRAME POPOVER.
   The component's count line (.cnd-count, css/rules.css) is toned for LIGHT surfaces — its #14171F
   text would vanish on this dark card (#141b2c). Same line, same states, re-toned for this surface:
   a legible foreground, muted labels, and "no matches" still in a warning tone without shouting. */
.cb-frm-condpop .cnd-count            { color: #e8ecf4; }
.cb-frm-condpop .cnd-count__k         { color: #8ea0bf; }
.cb-frm-condpop .cnd-count__err       { color: #ffb4ab; }
.cb-frm-condpop .cnd-count__spin      { border-color: #2b3550; border-top-color: #b9c2ff; }
.cb-frm-condpop .cb-mc--all strong    { color: #7fe0b0; }
.cb-frm-condpop__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12.5px; font-weight: 700; color: #e8ecf4; }
.cb-frm-condpop__sub { margin: 5px 0 10px; font-size: 11.5px; line-height: 1.55; color: #7f90ae; }
.cb-frm-pane { position: relative; }

/* At the 15s limit Meta and TikTok accept. Amber rather than red: the deck is valid and will
   render — it just cannot grow, which is why a frame's duration stops taking the value typed. */
.cb-frm-total.is-capped { color: #9A6B0E; }
/* The total is the DESIGN's length; for the previewed product some frames are conditioned out and
   the clip is shorter. Marked with a dotted underline rather than a warning colour — the number is
   not wrong, it just has a caveat, and the tooltip carries it. */
.cb-frm-total.has-condoff { text-decoration: underline dotted currentColor; text-underline-offset: 3px; cursor: help; }
/* OVER the limit: the render will truncate the end, so this one is a loss, not a ceiling. */
.cb-frm-total.is-over { color: #B91C1C; }

/* ── SOUND sidebar (2026-10-31): opened by the dock's Sound button next to Onion skin. Holds ONLY the
   soundtrack control (cbRenderSoundtrackInto) — the same one the right panel shows. ─────────────── */
.cb-bdock-sound { max-width: 220px; }
.cb-bdock-sound span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-bdock-sound.is-open { box-shadow: 0 0 0 2px #c7d2fe; }
.cb-snd-drawer {
    position: fixed; top: 56px; right: 0; bottom: 0; width: 360px; max-width: calc(100vw - 16px);
    background: #fff; border-left: 1px solid var(--border-color, #e5e7eb);
    box-shadow: -12px 0 32px rgba(20, 23, 31, .12); z-index: 1200;
    display: flex; flex-direction: column; animation: cbSndIn .16s ease-out;
}
@keyframes cbSndIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.cb-snd-drawer__head {
    display: grid; grid-template-columns: auto 1fr auto; align-items: center; column-gap: 9px; row-gap: 2px;
    padding: 14px 16px 12px; border-bottom: 1px solid var(--border-color, #e5e7eb); color: #5B53E8;
}
.cb-snd-drawer__title { font-size: 15px; font-weight: 700; color: var(--text-primary, #111827); }
.cb-snd-drawer__sub { grid-column: 2 / 4; grid-row: 2; font-size: 12px; line-height: 1.45; color: var(--text-secondary, #6b7280); }
.cb-snd-drawer__body { flex: 1; overflow-y: auto; padding: 4px 4px 16px; }
.cb-snd-drawer__section { border: 0; }
@media (max-width: 720px) { .cb-snd-drawer { top: 0; width: 100vw; max-width: 100vw; } }

/* Admin editing a BUILT-IN preset (template chooser pencil): says the save is global. */
.cb-preset-edit-bar {
    position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 1200;
    display: flex; align-items: center; gap: 10px; max-width: min(860px, calc(100vw - 32px));
    padding: 8px 10px 8px 12px; border-radius: 12px;
    background: #fff; border: 1px solid var(--accent, #5B53E8);
    box-shadow: 0 10px 28px rgba(15, 23, 42, .18);
    font-size: 13px; line-height: 1.35; color: var(--text-primary, #111827);
}
.cb-preset-edit-tag {
    flex: none; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
    letter-spacing: .02em; text-transform: uppercase; background: var(--accent, #5B53E8); color: #fff;
}
.cb-preset-edit-text { flex: 1 1 auto; min-width: 0; }
.cb-preset-edit-bar .btn { flex: none; white-space: nowrap; }
@media (max-width: 720px) { .cb-preset-edit-bar { flex-wrap: wrap; } }

/* MP4 preview popup: the Download button under the clip. */
.cb-rp-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* ── Auto Layout panel (js/editor/canvas.js cbAlFramePanel / cbAlChildPanel / cbAlAddPanel) ── */
.cb-al-panel .cb-al-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.cb-al-panel .cb-al-head h3 { margin: 0; }
.cb-al-row { flex-wrap: wrap; gap: 6px; }
.cb-al-row > label:first-child { min-width: 64px; }
.cb-al-seg { flex: 1; min-width: 0; flex-wrap: wrap; }
.cb-al-seg .bx-seg-btn { padding: 5px 9px; font-size: 12px; }
.cb-al-num { width: 64px; }
.cb-al-num--sm { width: 52px; }
.cb-al-suf { font-size: 11px; color: var(--text-muted); }
/* Slider rows (2026-11-07): range + number box, and the one-value / four-values toggle */
.cb-al-row--range { flex-wrap: nowrap; align-items: center; }
.cb-al-range { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.cb-al-range__slider { flex: 1; min-width: 60px; accent-color: var(--accent, #5B53E8); cursor: pointer; }
.cb-al-range__slider:disabled { opacity: .45; cursor: not-allowed; }
.cb-al-range .prop-input.cb-al-num { flex: 0 0 52px; width: 52px; min-width: 0; padding-left: 6px; padding-right: 6px; text-align: right; }
.cb-al-split-cell .prop-input.cb-al-num { padding-left: 2px; padding-right: 2px; }
.cb-al-range .prop-input.cb-al-num, .cb-al-split-cell .prop-input.cb-al-num { -moz-appearance: textfield; appearance: textfield; }
.cb-al-range .prop-input.cb-al-num::-webkit-inner-spin-button, .cb-al-range .prop-input.cb-al-num::-webkit-outer-spin-button,
.cb-al-split-cell .prop-input.cb-al-num::-webkit-inner-spin-button, .cb-al-split-cell .prop-input.cb-al-num::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.cb-al-linked.is-split { align-items: flex-start; }
.cb-al-linked--row.is-split > label:first-child { padding-top: 16px; }
.cb-al-linked--grid.is-split > label:first-child { padding-top: 7px; }
.cb-al-split4 { display: grid; gap: 4px; flex: 1; min-width: 0; }
.cb-al-split4--row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cb-al-split4--grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cb-al-split3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cb-al-split-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; color: var(--text-muted); }
.cb-al-split4--grid .cb-al-split-cell { flex-direction: row; gap: 5px; }
.cb-al-split4--grid .cb-al-split-tag { width: 12px; text-align: center; font-size: 12px; }
.cb-al-split-cell .cb-al-num { width: 100%; min-width: 0; text-align: center; }
.cb-al-split-btn { flex: 0 0 auto; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border, #E2E4EA); border-radius: 7px; background: #fff; color: var(--text-secondary, #5B6473); cursor: pointer; padding: 0; transition: border-color .12s, background .12s, color .12s; }
.cb-al-split-btn:hover { border-color: #C9C5F5; color: var(--accent, #5B53E8); }
.cb-al-split-btn.is-on { border-color: var(--accent, #5B53E8); background: #F7F6FE; color: var(--accent, #5B53E8); }
.cb-al-split-btn:focus-visible { outline: 2px solid var(--accent, #5B53E8); outline-offset: 2px; }
.cb-al-linked--row.is-split .cb-al-split-btn { margin-top: 14px; }
.cb-al-none, .cb-al-check { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-secondary, #5B6473); cursor: pointer; }
.cb-al-check input, .cb-al-none input { accent-color: var(--accent, #5B53E8); }
.cb-al-flags { gap: 14px; }
.cb-al-minmax .cb-al-num--sm { flex: 1; min-width: 44px; }
/* The browser's spinner ate the room the placeholder needs ("min V", "max \\"): no spinner, tighter padding. */
.cb-al-minmax .prop-input.cb-al-num--sm { padding-left: 4px; padding-right: 4px; text-align: center; -moz-appearance: textfield; appearance: textfield; }
.cb-al-minmax .cb-al-num--sm::-webkit-inner-spin-button, .cb-al-minmax .cb-al-num--sm::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.cb-al-anchor { display: grid; grid-template-columns: repeat(3, 18px); gap: 4px; padding: 4px; border: 1px solid var(--border, #E2E4EA); border-radius: 8px; }
.cb-al-anchor-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #CBD0D8; background: #fff; cursor: pointer; padding: 0; }
.cb-al-anchor-dot.is-on { border-color: var(--accent, #5B53E8); background: var(--accent, #5B53E8); }
.cb-al-anchor-dot:focus-visible, .cb-al-kid:focus-visible { outline: 2px solid var(--accent, #5B53E8); outline-offset: 2px; }
.cb-al-kids-head { margin: 10px 0 6px; font-size: 11px; color: var(--text-muted); }
.cb-al-kids { display: flex; flex-direction: column; gap: 4px; }
.cb-al-kid { display: flex; align-items: center; gap: 6px; padding: 5px 6px; border: 1px solid var(--border, #E2E4EA); border-radius: 8px; background: #fff; font-size: 12px; cursor: grab; }
.cb-al-kid.is-drag { opacity: .5; }
.cb-al-kid.is-over { border-color: var(--accent, #5B53E8); box-shadow: 0 0 0 2px rgba(91, 83, 232, .15); }
.cb-al-grip { color: #646B78; letter-spacing: -2px; }
.cb-al-kid-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-al-kid-size { font-size: 10.5px; color: var(--text-muted); white-space: nowrap; }
.cb-al-note { margin-top: 8px; font-size: 11.5px; color: #6B7280; line-height: 1.5; }
.cb-al-add { width: 100%; justify-content: center; }

/* Action inside a toast (e.g. "How to fix" on a blocked product image → AdPlex ImageBot guide). */
.toast .toast-action {
    margin-left: 6px; padding: 4px 10px; border-radius: 6px; border: 1px solid rgba(255,255,255,.45);
    background: transparent; color: inherit; font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.toast .toast-action:hover { background: rgba(255,255,255,.14); }

/* ── AI template assistant (js/editor/template-ai.js, 2026-11-07) ── */
.tai-toolbar-btn { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; color: #5B53E8; border-color: #D9D6FB; background: #F7F6FE; }
.tai-toolbar-btn:hover { background: #EEECFD; border-color: #C9C5F5; }
.tai-overlay { position: fixed; inset: 0; z-index: 1300; background: rgba(15, 18, 26, 0.28); display: flex; justify-content: flex-end; }
.tai-panel { width: 460px; max-width: 100vw; height: 100%; background: #fff; box-shadow: -18px 0 48px rgba(16, 24, 40, 0.22); display: flex; flex-direction: column; font-family: inherit; }
.tai-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 16px 18px 12px; border-bottom: 1px solid #F0F1F4; }
.tai-head h3 { margin: 0 0 3px; font-size: 16px; color: #14171F; }
.tai-head p { margin: 0; font-size: 12px; color: #6B7280; line-height: 1.4; }
.tai-body { flex: 1; overflow-y: auto; padding: 16px 18px 22px; display: flex; flex-direction: column; gap: 12px; }
.tai-row { display: flex; flex-direction: column; gap: 6px; }
.tai-row__l { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #6B7280; }
.tai-seg { display: flex; gap: 4px; padding: 3px; background: #F4F5F8; border-radius: 9px; }
.tai-seg__b { flex: 1; appearance: none; border: 0; background: transparent; padding: 7px 10px; border-radius: 7px; font-family: inherit; font-weight: 600; font-size: 12.5px; line-height: 1.2; color: #4A5160; cursor: pointer; }
.tai-seg__b.is-on { background: #fff; color: #14171F; box-shadow: 0 1px 3px rgba(16, 24, 40, .12); }
.tai-seg__b:disabled { opacity: .4; cursor: not-allowed; }
.tai-seg__b:focus-visible { outline: 2px solid #5B53E8; outline-offset: 1px; }
.tai-ta { width: 100%; box-sizing: border-box; resize: vertical; min-height: 92px; font-family: inherit; font-size: 13px; line-height: 1.45; }   /* "font: 13px/1.45 inherit" is invalid (keyword inside the shorthand) and was dropped → monospace */
.tai-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tai-chip { appearance: none; border: 1px solid #E2E4EA; background: #fff; border-radius: 999px; padding: 5px 10px; font-family: inherit; font-size: 12px; line-height: 1.3; color: #4A5160; cursor: pointer; text-align: left; }
.tai-chip:hover { border-color: #C9C5F5; color: #5B53E8; }
.tai-note { margin: 0; font-size: 11.5px; color: #6B7280; line-height: 1.45; }
.tai-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.tai-loading { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #4A5160; padding: 20px 0; }
.tai-spin { width: 16px; height: 16px; border: 2px solid #E2E4EA; border-top-color: #5B53E8; border-radius: 50%; animation: tai-spin .8s linear infinite; }
@keyframes tai-spin { to { transform: rotate(360deg); } }
.tai-meta { margin: 0; font-size: 11px; color: #6B7280; }
.tai-summary { margin: 0; font-size: 13.5px; color: #14171F; line-height: 1.45; font-weight: 600; }
.tai-h { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #6B7280; margin-top: 4px; }
.tai-h--warn { color: #B45309; }
.tai-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: #3B414C; line-height: 1.45; }
.tai-list--warn { color: #B45309; }
.tai-ops li::marker { color: #5B53E8; font-weight: 700; }
.tai-dropped summary { cursor: pointer; font-size: 12px; color: #6B7280; }
.tai-dropped .tai-list { margin-top: 6px; color: #6B7280; }
.tai-err { padding: 10px 12px; border-radius: 9px; background: #FEF3F2; color: #B42318; font-size: 12.5px; line-height: 1.45; }
.tai-err--soft { background: #FFFAEB; color: #B45309; }
.tai-ba, .tai-renders { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tai-renders { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tai-ba figure, .tai-renders figure { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.tai-ba img, .tai-renders img { width: 100%; border-radius: 8px; border: 1px solid #E2E4EA; background: #F4F5F8; display: block; }
.tai-ba figcaption, .tai-renders figcaption { font-size: 11px; color: #6B7280; text-align: center; }
.tai-ph { aspect-ratio: 1 / 1; border-radius: 8px; border: 1px dashed #D5D8DE; display: flex; align-items: center; justify-content: center; font-size: 11px; color: #6B7280; text-align: center; padding: 6px; }
.tai-ph--err { color: #B42318; border-color: #FDA29B; }
@media (max-width: 520px) { .tai-panel { width: 100vw; } .tai-renders { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* AI assistant — inspiration picker (2026-11-07) */
.tai-insp { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px; border: 1px dashed #D5D8DE; border-radius: 10px; background: #FAFAFB; }
.tai-insp.is-over { border-color: var(--accent, #5B53E8); background: #F1F0FD; }
.tai-insp.has-img { border-style: solid; background: #fff; }
.tai-insp__file { display: none; }
.tai-insp__btn { font-size: 12.5px; }
.tai-insp__hint { font-size: 12px; color: #6B7280; line-height: 1.4; }
.tai-insp__thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid #E2E4EA; }
.tai-insp__txt { flex: 1 1 180px; display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; color: #14171F; }
.tai-insp__txt span { color: #6B7280; font-size: 12px; }
.tai-insp__rm { font-size: 12px; }

/* Preview product in the TOP BAR, after the safe-zones toggle (2026-11-07) */
.tb-preview-product { display: inline-flex; align-items: center; margin-left: 8px; min-width: 0; max-width: 300px; }
.tb-preview-product .tpl-preview-pick { margin: 0; padding: 0; border: 0; background: none; width: 100%; }
.tb-preview-product .cb-preview-row { display: flex; align-items: center; gap: 4px; min-width: 0; }
.tb-preview-product .cb-preview-arrow { width: 28px; height: 28px; flex: 0 0 28px; }
@media (max-width: 1500px) { .tb-preview-product { max-width: 250px; } .tb-preview-product .cb-psp-price { display: none; } }
/* "Turn off background removal everywhere" (free plans: catalog renders use the original images). */
.tb-bg-off { display: inline-flex; align-items: center; margin-left: 6px; }
.tb-bg-off-btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 8px;
    border: 1px solid var(--border, #e2e4ea); background: var(--surface, #fff); color: var(--text-secondary, #4b5060);
    font: 500 12.5px/1 inherit; cursor: pointer; white-space: nowrap; }
.tb-bg-off-btn:hover { border-color: var(--accent, #5B53E8); color: var(--accent, #5B53E8); }
.tb-bg-off-btn:focus-visible { outline: 2px solid var(--accent, #5B53E8); outline-offset: 2px; }
.tb-bg-off-btn.is-warn { border-color: #f5c46b; background: #fff8eb; color: #8a5300; }
.tb-bg-off-btn.is-warn:hover { border-color: #e0a12f; color: #6b4000; }
.cb-bg-free-hint { color: #8a5300; }
.tb-bg-off-cnt { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: rgba(0,0,0,.08); font-size: 11px;
    display: inline-flex; align-items: center; justify-content: center; }
/* The toolbar is full at common laptop widths: icon + count there (the tooltip + aria-label say the rest). */
@media (max-width: 1640px) { .tb-bg-off-lbl { display: none; } }
/* NARROW EDITOR (≤1280px: small laptops, tablets). The toolbar is ~1160px of fixed-width controls, so below
   ~1240px the right end — Save, the quality check and the product picker — sat off-screen behind
   .main-content's overflow:hidden with no way to reach it (QA 2026-11-08, 1024×768: Save at x=1151).
   Shrink what can shrink (name, picker, padding) and let the bar scroll sideways for the rest. Every
   toolbar popover (zoom menu, product list) is position:fixed on <body>, so the scroll clips none of them. */
@media (max-width: 1280px) {
    .editor-toolbar { padding: 0 8px; gap: 8px; min-width: 0; max-width: 100%; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
    .toolbar-center, .toolbar-right { flex-shrink: 0; }
    .toolbar-left { flex: 0 1 auto; min-width: 96px; }
    .toolbar-left .design-name-input { width: 100%; min-width: 60px; max-width: 220px; }
    .tb-preview-product { max-width: 170px; }
}
/* Compact card that fits the 52px toolbar: 32px tall, one line (title · price), thumb 24px, no ID line. */
.tb-preview-product .cb-psp-trigger { height: 34px; padding: 3px 8px; gap: 8px; border-radius: 8px; }
.tb-preview-product .cb-psp-thumb { width: 26px; height: 26px; border-radius: 5px; }
.tb-preview-product .cb-psp-lbl { flex-direction: row; align-items: center; gap: 8px; }
.tb-preview-product .cb-psp-title { font-size: 12.5px; flex: 1 1 auto; min-width: 0; }
.tb-preview-product .cb-psp-id { display: none; }
.tb-preview-product .cb-psp-price { margin: 0; flex: 0 0 auto; flex-wrap: nowrap; }
.tb-preview-product .cb-preview-arrow { align-self: center; }

/* AI template assistant INSIDE the left AI Media panel (2026-11-07) */
.tai-panel--inline { width: auto; max-width: none; height: auto; box-shadow: none; background: transparent; }
.tai-panel--inline .tai-head { padding: 4px 0 10px; }
.tai-panel--inline .tai-body { padding: 0; overflow: visible; }
.tai-panel--inline .tai-renders { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tai-panel--inline .tai-seg__b { padding-left: 6px; padding-right: 6px; font-size: 12.5px; }
/* On the left panel's light-grey background the shared muted grey (#6B7280) is ~4.4:1 — darker inside the inline panel (AA). */
.tai-panel--inline .tai-head p, .tai-panel--inline .tai-row__l, .tai-panel--inline .tai-note, .tai-panel--inline .tai-meta,
.tai-panel--inline .tai-h, .tai-panel--inline .tai-insp__hint, .tai-panel--inline .tai-insp__txt span { color: #4B5563; }

/* AI assistant — brand-kit preview under the Use / Don't use switch (2026-11-07) */
.tai-bk { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: -4px; }
.tai-bk__sw { width: 18px; height: 18px; border-radius: 5px; border: 1px solid rgba(17, 24, 39, 0.12); }
.tai-bk__f { font-size: 12px; color: #4B5563; margin-left: 4px; }

/* AI assistant — variations picker + refine box (2026-11-07) */
.tai-variants { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 900px) { .tai-panel:not(.tai-panel--inline) .tai-variants { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tai-variant { display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px solid #E2E4EA; border-radius: 10px; background: #fff; }
.tai-variant img, .tai-variant .tai-ph { width: 100%; aspect-ratio: 1 / 1; object-fit: contain; border-radius: 8px; background: #F5F6F8; }
.tai-variant__s { margin: 0; font-size: 12.5px; line-height: 1.45; color: #14171F; }
.tai-variant .bx-primary { align-self: flex-start; }
.tai-refine { display: flex; gap: 6px; align-items: center; }
.tai-refine__in { flex: 1 1 auto; min-width: 0; }
/* The inline assistant must never make the AI Media panel scroll sideways (long words, the refine input, variant cards). */
#ai-subtab-content, #ai-edits-content { overflow-x: hidden; }
.tai-panel--inline, .tai-panel--inline .tai-body, .tai-panel--inline .tai-variant { min-width: 0; max-width: 100%; box-sizing: border-box; }
.tai-panel--inline .tai-variant__s, .tai-panel--inline .tai-summary, .tai-panel--inline .tai-list { overflow-wrap: anywhere; }
/* Five AI Media subtabs (with "AI template") no longer fit one row in the 299px panel: they wrap, and the panel never
   scrolls sideways (it did, cutting the start of every line, 2026-11-07). */
.ai-subtabs { flex-wrap: wrap; }
.ai-subtab { flex: 1 1 auto; }
#left-panel-content { overflow-x: hidden; }

/* Brand kit + recent colours under every colour picker (canvas.js recentColorsHTML / enhanceColorInputs) */
.cb-palette { display: flex; flex-direction: column; }
.cb-palette .prop-row { margin-top: -2px; }
.doc-color-swatch.brand-kit-swatch { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35); }
.ft-popover-label { font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #6B7280; margin-bottom: -4px; }
/* An image layer: a small thumbnail of what it shows now, before its name (2026-11-08) */
.layer-name-row { flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; }
.layer-name-row .layer-name { flex: 1; min-width: 0; }
.layer-thumb { width: 22px; height: 22px; flex: none; border-radius: 4px; background: #F1F2F6; box-shadow: inset 0 0 0 1px rgba(17, 24, 39, .08); }
.layer-name-row.is-child { padding-left: 0.6em; }

/* ── WCAG contrast check of the final render (js/editor/render-contrast.js, 2026-11-09) ── */
.lint-panel-actions { padding: 10px 14px 0; }
.lint-contrast-btn { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.lint-contrast-status { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.lint-contrast-status__row { font-size: 12.5px; font-weight: 600; border-radius: 8px; padding: 6px 10px; line-height: 1.4; }
.lint-contrast-status__row[data-kind="ok"] { color: #046c4e; background: #e7f8ef; }
.lint-contrast-status__row[data-kind="warn"] { color: #93370d; background: #fef6e7; }
.lint-contrast-status__row[data-kind="bad"] { color: #b42318; background: #fdecea; }
.lint-contrast-status__row[data-kind="muted"] { color: #4b5563; background: #f3f4f6; font-weight: 500; }
.cb-wcag-overlay { z-index: 1500; }   /* above the quality-check panel (1400) it is opened from */
.cb-wcag-modal { width: min(1040px, 94vw); max-height: 90vh; background: #fff; border-radius: 14px; display: flex; flex-direction: column;
    overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.cb-wcag-head { display: flex; align-items: center; gap: 16px; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--border-color, #e5e7eb); }
.cb-wcag-htext { flex: 1; min-width: 0; }
.cb-wcag-head h3 { margin: 0; font-size: 16px; }
.cb-wcag-source { font-size: 12.5px; color: #6b7280; margin-top: 2px; }
.cb-wcag-seg { display: inline-flex; border: 1px solid var(--border-color, #e5e7eb); border-radius: 8px; overflow: hidden; flex: 0 0 auto; }
.cb-wcag-segbtn { border: 0; background: #fff; padding: 6px 14px; font: 600 12.5px/1 inherit; color: #4b5563; cursor: pointer; }
.cb-wcag-segbtn + .cb-wcag-segbtn { border-left: 1px solid var(--border-color, #e5e7eb); }
.cb-wcag-segbtn.is-on { background: var(--accent, #5B53E8); color: #fff; }
.cb-wcag-segbtn:focus-visible { outline: 2px solid var(--accent, #5B53E8); outline-offset: -2px; }
.cb-wcag-body { padding: 16px 20px 18px; overflow: auto; }
.cb-wcag-loading { color: #6b7280; font-size: 13px; padding: 40px; text-align: center; }
.cb-wcag-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.cb-wcag-pill { font-size: 12.5px; font-weight: 600; border-radius: 999px; padding: 4px 10px; }
.cb-wcag-pill.is-ok { color: #046c4e; background: #e7f8ef; }
.cb-wcag-pill.is-bad { color: #b42318; background: #fdecea; }
.cb-wcag-pill.is-muted { color: #4b5563; background: #f3f4f6; }
.cb-wcag-need { font-size: 12px; color: #6b7280; }
.cb-wcag-section + .cb-wcag-section { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border-color, #e5e7eb); }
.cb-wcag-sectitle { font-weight: 600; font-size: 13px; margin-bottom: 8px; }
.cb-wcag-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 760px) { .cb-wcag-grid { grid-template-columns: 1fr; } }
.cb-wcag-fig { position: relative; line-height: 0; border: 1px solid var(--border-color, #e5e7eb); border-radius: 8px; overflow: hidden; background: #f4f4f6; }
.cb-wcag-img { width: 100%; height: auto; display: block; }
.cb-wcag-box { position: absolute; border: 2px solid; border-radius: 3px; pointer-events: none; transition: box-shadow .12s; }
.cb-wcag-box.is-ok { border-color: #12b76a; }
.cb-wcag-box.is-bad { border-color: #f04438; }
.cb-wcag-box.is-na { border-color: #98a2b3; border-style: dashed; }
.cb-wcag-box.is-hl { box-shadow: 0 0 0 3px rgba(91,83,232,.55); }
.cb-wcag-box .cb-wcag-num { position: absolute; top: -10px; left: -10px; }
.cb-wcag-num { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
    background: #111827; color: #fff; font: 600 11px/1 inherit; }
.cb-wcag-box.is-ok .cb-wcag-num { background: #067647; }
.cb-wcag-box.is-bad .cb-wcag-num { background: #b42318; }
.cb-wcag-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cb-wcag-row { border: 1px solid var(--border-color, #e5e7eb); border-left-width: 4px; border-radius: 8px; padding: 9px 11px; cursor: default; }
.cb-wcag-row[title] { cursor: pointer; }
.cb-wcag-row:hover, .cb-wcag-row:focus-visible { background: #f9fafb; outline: none; }
.cb-wcag-row.is-ok { border-left-color: #12b76a; }
.cb-wcag-row.is-bad { border-left-color: #f04438; }
.cb-wcag-row.is-na { border-left-color: #98a2b3; color: #4b5563; font-size: 12.5px; }
.cb-wcag-rowtop { display: flex; align-items: center; gap: 8px; }
.cb-wcag-name { font-weight: 600; font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-wcag-ratio { font: 700 13px/1 inherit; font-variant-numeric: tabular-nums; }
.cb-wcag-text { font-size: 12px; color: #6b7280; margin: 4px 0 0 28px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-wcag-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0 0 28px; font-size: 12px; color: #4b5563; }
.cb-wcag-sw { width: 14px; height: 14px; border-radius: 4px; border: 1px solid rgba(0,0,0,.15); display: inline-block; }
.cb-wcag-size { margin-right: auto; }
.cb-wcag-badge { font-weight: 700; font-size: 11px; border-radius: 6px; padding: 2px 6px; }
.cb-wcag-badge.is-ok { color: #046c4e; background: #e7f8ef; }
.cb-wcag-badge.is-bad { color: #b42318; background: #fdecea; }
.cb-wcag-fix { font-size: 12px; color: #374151; margin: 6px 0 0 28px; line-height: 1.45; }
.cb-wcag-row.is-na .cb-wcag-fix { margin-left: 28px; }
.cb-wcag-foot { font-size: 11.5px; color: #6b7280; margin: 16px 0 0; line-height: 1.5; }

/* ── Preview on 20 products (cbOpenProductPreview, 2026-11-09) ── */
.cb-pv-open { display: inline-flex; align-items: center; gap: 6px; }
.cb-pv-overlay { z-index: 1500; }
.cb-pv-modal { width: min(1180px, 95vw); max-height: 92vh; background: #fff; border-radius: 14px; display: flex; flex-direction: column;
    overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.cb-pv-head { display: flex; align-items: center; gap: 14px; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--border-color, #e5e7eb); }
.cb-pv-htext { flex: 1; min-width: 0; }
.cb-pv-head h3 { margin: 0; font-size: 16px; }
.cb-pv-sub { font-size: 12.5px; color: #6b7280; margin-top: 2px; }
.cb-pv-ctrls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cb-pv-seg { display: inline-flex; border: 1px solid var(--border-color, #e5e7eb); border-radius: 8px; overflow: hidden; }
.cb-pv-segbtn { border: 0; background: #fff; padding: 6px 12px; font: 600 12.5px/1 inherit; color: #4b5563; cursor: pointer; }
.cb-pv-segbtn + .cb-pv-segbtn { border-left: 1px solid var(--border-color, #e5e7eb); }
.cb-pv-segbtn.is-on { background: var(--accent, #5B53E8); color: #fff; }
.cb-pv-segbtn:focus-visible { outline: 2px solid var(--accent, #5B53E8); outline-offset: -2px; }
.cb-pv-intro { padding: 10px 20px; font-size: 12.5px; color: #4b5563; background: #f8f8fb; border-bottom: 1px solid var(--border-color, #e5e7eb); }
/* One product per row, the desktop + phone placement side by side at REAL CSS sizes — never scaled to fit: the row scrolls sideways instead. */
.cb-pv-body { padding: 14px 20px; overflow: auto; }
.cb-pv-list { display: flex; flex-direction: column; gap: 14px; }
.cb-pv-row { border: 1px solid var(--border-color, #e5e7eb); border-radius: 12px; padding: 12px 14px; background: #fff; }
.cb-pv-row.is-skipped .cb-pv-media img { opacity: .45; filter: grayscale(1); }
.cb-pv-rowinfo { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; font-size: 13px; }
.cb-pv-rown { min-width: 22px; height: 22px; border-radius: 11px; background: #eef0f4; color: #374151; font: 700 11.5px/22px inherit; text-align: center; }
.cb-pv-rowt { font-weight: 600; color: #111827; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-pv-rowp { color: #4b5563; }
.cb-pv-tag { font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 999px; }
.cb-pv-tag.is-ok { color: #046c4e; background: #e7f8ef; }
.cb-pv-tag.is-warn { color: #93370d; background: #fef6e7; }
.cb-pv-tag.is-bad { color: #b42318; background: #fdecea; }
.cb-pv-tag.is-skip { color: #93370d; background: #fef6e7; }
.cb-pv-devices { display: flex; gap: 28px; align-items: flex-start; overflow-x: auto; padding-bottom: 4px; }
.cb-pv-dev { flex: none; }
.cb-pv-devlabel { font-size: 11.5px; font-weight: 600; color: #6b7280; margin-bottom: 6px; }
/* Post chrome — Facebook-like, system font, white card on the feed's grey. */
.cb-pv-post { flex: none; box-sizing: border-box; background: #fff; border: 1px solid #dadde1; border-radius: 8px; overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; color: #050505; }
.cb-pv-dev--phone .cb-pv-post { border-radius: 22px; border: 6px solid #1f2937; }
.cb-pv-post--story { background: #000; }
.cb-pv-post-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 6px; }
.cb-pv-avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #c7cbe0, #8f96b8); flex: none; }
.cb-pv-page { font-size: 14px; font-weight: 600; line-height: 1.2; }
.cb-pv-spons { font-size: 12px; color: #65676b; }
.cb-pv-primary { padding: 0 12px 8px; font-size: 14px; line-height: 1.35; }
.cb-pv-track { display: flex; gap: 8px; padding: 0 0 10px 12px; overflow: hidden; }
.cb-pv-post--story .cb-pv-track, .cb-pv-post--feed .cb-pv-track { padding: 0; gap: 0; }
.cb-pv-card { flex: none; border: 1px solid #dadde1; border-radius: 8px; overflow: hidden; background: #fff; }
.cb-pv-post--story .cb-pv-card, .cb-pv-post--feed .cb-pv-card { border: 0; border-radius: 0; }
.cb-pv-media { background: #f0f2f5; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.cb-pv-media img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cb-pv-media-wait { font-size: 12px; color: #646B78; }
.cb-pv-strip { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #f0f2f5; }
.cb-pv-strip-t { flex: 1; min-width: 0; }
.cb-pv-strip-h { font-size: 14px; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-pv-strip-d { font-size: 12px; color: #65676b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 15px; }
.cb-pv-cta { flex: none; font-size: 13px; font-weight: 600; background: #e4e6eb; border-radius: 6px; padding: 6px 10px; }
.cb-pv-foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border-color, #e5e7eb); }
.cb-pv-footnote { flex: 1; font-size: 12px; color: #6b7280; }

/* ── Product tags panel (buildProductInsertSection, 2026-11-09): thumbnails for images, 1-line value previews ── */
.cb-ptags-sample { font-size: 11.5px; color: var(--text-muted); margin: 0 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-ptags-filter { width: 100%; box-sizing: border-box; height: 32px; padding: 0 10px; margin: 2px 0 2px; border: 1px solid var(--border);
    border-radius: 8px; font: inherit; font-size: 12.5px; background: var(--bg-secondary); color: var(--text-primary); }
.cb-ptags-filter:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,83,232,.15); }
.cb-ptags-sec .insert-section-label { margin: 14px 0 6px; }
.cb-ptags-sec.is-quiet { opacity: .8; }
/* images: a grid of real thumbnails */
.cb-ptags-imgs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.cb-ptags-img { display: flex; flex-direction: column; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg-secondary); cursor: pointer; font: inherit; text-align: left; min-width: 0; transition: border-color var(--transition), background var(--transition); }
.cb-ptags-img:hover { border-color: var(--accent); background: var(--bg-hover); }
.cb-ptags-img:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cb-ptags-thumb { display: flex; align-items: center; justify-content: center; aspect-ratio: 1 / 1; border-radius: 5px; overflow: hidden;
    background: #f4f4f6 repeating-conic-gradient(#eceef2 0% 25%, transparent 0% 50%) 50% / 12px 12px; font-size: 10.5px; color: var(--text-muted); }
.cb-ptags-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cb-ptags-img.is-empty .cb-ptags-thumb { background: var(--bg-subtle, #f3f4f6); font-style: italic; }
.cb-ptags-img-l { font-size: 11px; font-weight: 500; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-ptags-img.is-empty .cb-ptags-img-l { color: var(--text-muted); }
/* text rows: label + a one-line value */
.cb-ptags-row { display: flex; align-items: center; gap: 9px; width: 100%; padding: 6px 10px; margin-bottom: 4px; border: 1px solid var(--border);
    border-radius: 8px; background: var(--bg-secondary); color: var(--text-primary); cursor: pointer; font: inherit; text-align: left;
    min-width: 0; transition: border-color var(--transition), background var(--transition); }
.cb-ptags-row:hover { border-color: var(--accent); background: var(--bg-hover); }
.cb-ptags-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cb-ptags-ic { display: inline-flex; color: var(--text-muted); flex-shrink: 0; }
.cb-ptags-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cb-ptags-l { font-size: 12.5px; font-weight: 500; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-ptags-v { font-size: 11.5px; line-height: 1.35; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-ptags-v.is-empty { font-style: italic; opacity: .75; }

/* AI IMAGE FIT status under the Fit option (2026-11-10) */
.cb-aifit-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 4px; padding: 8px 10px; border-radius: 8px; font-size: 12px; line-height: 1.4; background: var(--surface-2, #f4f4f8); color: var(--text, #222); }
.cb-aifit-status.is-cached, .cb-aifit-status.is-painted, .cb-aifit-status.is-same-shape { background: #ecfdf3; color: #05603a; }
.cb-aifit-status.is-failed, .cb-aifit-status.is-refused, .cb-aifit-status.is-no-storage { background: #fef3f2; color: #b42318; }
.cb-aifit-status__text { flex: 1 1 160px; }
.cb-aifit-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: cb-aifit-spin .8s linear infinite; flex: 0 0 auto; }
@keyframes cb-aifit-spin { to { transform: rotate(360deg); } }
