/* ==================== AI Studio ==================== */

.vstudio-layout {
    position: fixed;
    /* Sits to the right of the persistent sidebar. Tied to
     * var(--sidebar-width) so any nav-width change propagates here
     * automatically (was hardcoded 56px). */
    inset: 0 0 0 var(--sidebar-width, 80px);
    transition: left 0.16s ease;
    display: flex;
    flex-direction: column;
    /* Use the app's font everywhere in the studio (not a design-tool/system default). */
    font-family: "IBM Plex Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg-secondary, #f7f7fa);
    z-index: 100;
}
/* Form controls don't inherit font-family by default, and the studio control panel
   is almost entirely buttons/selects/inputs — so they were rendering in the UA
   default font instead of the app font. Force them to inherit it. (All other text
   already inherits via body's var(--font); intentional monospace spans aren't form
   controls, so they keep their own font.) */
.vstudio-layout button,
.vstudio-layout input,
.vstudio-layout select,
.vstudio-layout textarea {
    font-family: inherit;
}

.vstudio-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    background: #fff;
    border-bottom: 1px solid var(--border-subtle, #e6e6ec);
    flex-shrink: 0;
}
.vstudio-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary, #1a1a2e);
}
.vstudio-header-sub {
    color: var(--text-muted, #888);
    font-size: 13px;
    margin-left: auto;
}

/* Side-column widths live on CSS variables so the JS resize handles
 * can update them directly. Defaults (320px) are the FLOOR — the
 * resize handles never let the user drag below this, only widen.
 * Grid template adds explicit 6px tracks for the handles between the
 * columns so they don't overlap the column content. */
.vstudio-main {
    display: grid;
    grid-template-columns:
        max(365px, var(--vstudio-left-w, 365px))
        6px
        1fr
        6px
        var(--vstudio-right-w, 320px);
    /* Bound the single row to the container height (instead of the default
       `auto`, which grows to content). Without this a tall column — e.g. the
       controls accordion with Concepts expanded — pushes past the viewport and
       gets clipped by overflow:hidden, so the column's own overflow-y:auto never
       gets anything to scroll. */
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
    flex: 1;
    overflow: hidden;
}
/* Let every column shrink to the bounded row so its internal overflow-y:auto
   actually scrolls (grid items default to min-height:auto = won't shrink). */
.vstudio-main > * { min-height: 0; }

/* Resize handles — the 6px tracks between left/center and center/right.
 * Hit area is the full 6px column; the visible affordance is a 2px
 * vertical line centered inside that, becoming indigo on hover/drag. */
.vstudio-resize-handle {
    position: relative;
    cursor: ew-resize;
    background: transparent;
    transition: background 0.12s ease;
    z-index: 5;
    user-select: none;
}
.vstudio-resize-handle:hover,
.vstudio-resize-handle.is-dragging {
    background: rgba(99, 102, 241, 0.06);
}
.vstudio-resize-handle-grip {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    transform: translateX(-50%);
    background: transparent;
    transition: background 0.12s ease;
    pointer-events: none;
}
.vstudio-resize-handle:hover .vstudio-resize-handle-grip,
.vstudio-resize-handle.is-dragging .vstudio-resize-handle-grip {
    background: rgba(99, 102, 241, 0.7);
}
/* Tiny grip dots in the middle of the handle so the affordance is
 * visible even before hover. Three short dashes stacked vertically. */
.vstudio-resize-handle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 24px;
    transform: translate(-50%, -50%);
    background: linear-gradient(
        to bottom,
        rgba(15, 23, 42, 0.18) 0%,
        rgba(15, 23, 42, 0.18) 30%,
        transparent 30%,
        transparent 50%,
        rgba(15, 23, 42, 0.18) 50%,
        rgba(15, 23, 42, 0.18) 70%,
        transparent 70%,
        transparent 90%,
        rgba(15, 23, 42, 0.18) 90%,
        rgba(15, 23, 42, 0.18) 100%
    );
    pointer-events: none;
    transition: background 0.12s ease;
}
.vstudio-resize-handle:hover::before,
.vstudio-resize-handle.is-dragging::before {
    background: rgba(99, 102, 241, 0.6);
}

/* ---- Left: Controls ---- */
.vstudio-controls {
    background: #fff;
    border-right: 1px solid var(--border-subtle, #e6e6ec);
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.vstudio-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary, #4b5563);   /* was #888 — too faint to read */
    margin-bottom: 4px;
    display: block;
}
/* Hairline divider above each TOP-LEVEL section label — visibly delimits the
   left panel into sections without heavy boxes (stays minimalist). */
.vstudio-controls > .vstudio-label {
    border-top: 1px solid var(--border-subtle, #eef0f4);
    padding-top: 14px;
    margin-top: 2px;
}
.vstudio-controls > .vstudio-label:first-child { border-top: none; padding-top: 0; margin-top: 0; }

/* ===== Image Studio Redesign — 4-step accordion control panel =====
   buildControls() builds the flat control stack, then accordionize() re-parents
   it into numbered collapsible cards. The col becomes header / scroll / sticky
   footer; the scroll holds the cards. Individual controls keep their own styles. */
/* The col itself is the scroller (robust — same as the pre-accordion panel);
   the header + Generate footer are position:sticky so they stay pinned while
   the cards scroll between them. (A flex header/scroll/footer split clipped the
   content because this col is a grid item whose row grows to content.) */
.vstudio-controls--acc { padding: 0; gap: 0; overflow-y: auto; }
.vstudio-acc-head { position: sticky; top: 0; z-index: 3; background: #fff; padding: 15px 18px; border-bottom: 1px solid #F0F1F4; }
.vstudio-acc-h1 { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; color: #14171F; }
.vstudio-acc-h2 { font-size: 11.5px; color: #6B7280; margin-top: 1px; }
.vstudio-acc-moderow { padding: 13px 18px 0; background: #fff; }
.vstudio-acc-scroll { padding: 14px 18px 16px; display: flex; flex-direction: column; gap: 11px; }
.vstudio-acc-card { border: 1px solid #E9EAEE; border-radius: 13px; background: #FBFBFC; overflow: hidden; }
.vstudio-acc-card.is-open { border-color: #D9D5F7; background: #FFFFFF; }
.vstudio-acc-card-head { width: 100%; display: flex; align-items: center; gap: 11px; background: none; border: none; cursor: pointer; padding: 13px 14px; text-align: left; }
.vstudio-acc-num { width: 24px; height: 24px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 700; flex: 0 0 auto; background: #ECEDF1; color: #8A93A1; }
.vstudio-acc-card.is-open .vstudio-acc-num { background: #5B53E8; color: #fff; }
.vstudio-acc-tt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.vstudio-acc-name { font-size: 13.5px; font-weight: 700; color: #14171F; }
.vstudio-acc-summary { font-size: 11.5px; color: #6B7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.vstudio-acc-chev { flex: 0 0 auto; display: flex; transition: transform 0.15s; }
.vstudio-acc-card.is-open .vstudio-acc-chev { transform: rotate(180deg); }
.vstudio-acc-body { padding: 2px 14px 14px; display: flex; flex-direction: column; gap: 12px; }
/* Cards own their spacing — drop the legacy top-level label divider inside them. */
.vstudio-acc-body > .vstudio-label { border-top: none; padding-top: 0; margin-top: 0; }
.vstudio-acc-nav { display: flex; align-items: center; gap: 9px; padding-top: 12px; border-top: 1px solid #F0F1F4; margin-top: 2px; }
.vstudio-acc-back { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: #5B6473; background: #FFFFFF; border: 1px solid #E2E4EA; border-radius: 9px; padding: 8px 13px; cursor: pointer; }
.vstudio-acc-back:hover { background: #F7F8FA; }
.vstudio-acc-next { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: #FFFFFF; background: #14171F; border: none; border-radius: 9px; padding: 8px 16px; cursor: pointer; }
.vstudio-acc-next:hover { background: #272B36; }
/* Sticky Generate footer — pinned to the bottom of the scrolling col. */
.vstudio-controls--acc .vstudio-footer { position: sticky; bottom: 0; z-index: 3; border-top: 1px solid #ECEDF1; padding: 13px 18px; background: #fff; margin: 0; }

/* ===== Custom (user-authored) concepts — per-account, saved server-side ===== */
.vstudio-custom-concepts { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.vstudio-custom-head { display: flex; align-items: center; gap: 7px; }
.vstudio-custom-title { font-size: 11px; font-weight: 700; letter-spacing: .04em; color: #646B78; text-transform: uppercase; }
.vstudio-custom-count { font-size: 11px; color: #646B78; }
.vstudio-custom-row { display: flex; align-items: center; gap: 4px; border-radius: 8px; }
.vstudio-custom-row.on { background: #F4F3FE; }
.vstudio-custom-toggle { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; border: none; background: none; cursor: pointer; text-align: left; padding: 7px 8px; }
.vstudio-custom-check { width: 17px; height: 17px; border-radius: 5px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; background: #FFFFFF; border: 1.5px solid #C2C9D4; }
.vstudio-custom-check svg { opacity: 0; }
.vstudio-custom-check.on { background: #5B53E8; border-color: #5B53E8; }
.vstudio-custom-check.on svg { opacity: 1; }
.vstudio-custom-name { flex: 1; min-width: 0; font-size: 12.5px; font-weight: 600; color: #2A3343; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vstudio-custom-del { width: 24px; height: 24px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; border: none; background: none; color: #646B78; cursor: pointer; border-radius: 6px; }
.vstudio-custom-del:hover { background: #FDEFEC; color: #C0492A; }
/* Sharing (v112): a "Shared" tag on a concept this project shares out; the source project's name on one
   shared IN (use-only here, so no edit/delete). The share switch in the form reuses the design system's .bx-switch. */
.vstudio-custom-tag { flex: 0 1 auto; min-width: 0; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; font-weight: 600; color: #4A43D6; background: #EEEDFD; border-radius: 999px; padding: 2px 8px; }
.vstudio-custom-tag.is-from { color: #5B6472; background: #F1F2F5; }
.vstudio-custom-row.is-foreign .vstudio-custom-name { color: #4A5261; }
.vstudio-custom-share { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border: 1px solid #E6E3FB; border-radius: 9px; background: #fff; }
.vstudio-custom-sharetxt { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.vstudio-custom-sharelbl { font-size: 12.5px; font-weight: 600; color: #2A3343; }
.vstudio-custom-sharehint { font-size: 10.5px; line-height: 1.45; color: #646B78; }
/* Collapsed-by-default "+ New custom concept" button (the form opens on click). */
.vstudio-custom-new { display: inline-flex; align-items: center; justify-content: center; gap: 7px; width: 100%; font-size: 12.5px; font-weight: 600; color: #5B53E8; background: #fff; border: 1px dashed #CFCBF6; border-radius: 10px; padding: 10px; cursor: pointer; margin-top: 2px; }
.vstudio-custom-new:hover { border-color: #5B53E8; background: #FBFAFF; }
/* The creator form — a violet-tinted card (title + close, name, desc, optimize, save). */
.vstudio-custom-creator { display: flex; flex-direction: column; gap: 7px; margin-top: 4px; border: 1px solid #D9D5F7; border-radius: 11px; background: #FBFAFF; padding: 12px; }
.vstudio-custom-chead { display: flex; align-items: center; gap: 8px; }
.vstudio-custom-ctitle { flex: 1; font-size: 12px; font-weight: 700; color: #3B414C; }
.vstudio-custom-optimize { display: inline-flex; align-items: center; gap: 5px; align-self: flex-start; font-size: 11.5px; font-weight: 600; color: #8A86C8; background: none; border: none; padding: 2px; cursor: pointer; }
.vstudio-custom-optimize:hover { color: #5B53E8; }
.vstudio-custom-name-in { width: 100%; border: 1px solid #E2E4EA; border-radius: 8px; padding: 8px 10px; font-size: 12.5px; outline: none; font-family: inherit; }
.vstudio-custom-name-in:focus, .vstudio-custom-desc-in:focus { border-color: #5B53E8; }
.vstudio-custom-desc-in { width: 100%; height: 62px; border: 1px solid #E2E4EA; border-radius: 8px; padding: 8px 10px; font-size: 12.5px; line-height: 1.5; outline: none; resize: none; font-family: inherit; }
.vstudio-custom-save { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: #fff; background: #5B53E8; border: none; border-radius: 9px; padding: 9px; cursor: pointer; }
.vstudio-custom-save:hover { background: #4A43D6; }
.vstudio-custom-save:disabled { opacity: 0.6; cursor: default; }
/* Custom-concept row extras (2026-07-14): sketch thumb + "more info" button. */
.vstudio-custom-thumb { width: 20px; height: 20px; flex: 0 0 auto; border-radius: 5px; object-fit: cover; border: 1px solid #E2E4EA; background: #F3F4F7; }
.vstudio-custom-infobtn { width: 24px; height: 24px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; border: none; background: none; color: #646B78; cursor: pointer; border-radius: 6px; }
.vstudio-custom-infobtn:hover { background: #ECEAF9; color: #5B53E8; }
/* Creator: optional inspiration/sketch image attach row. */
.vstudio-custom-sketchbtn { display: inline-flex; align-items: center; gap: 6px; width: 100%; justify-content: center; font-size: 11.5px; font-weight: 600; color: #6B7280; background: #fff; border: 1px dashed #D8DBE2; border-radius: 8px; padding: 8px; cursor: pointer; }
.vstudio-custom-sketchbtn:hover { border-color: #5B53E8; color: #5B53E8; }
.vstudio-custom-sketchbtn:disabled { opacity: 0.6; cursor: default; }
.vstudio-custom-sketchfile { display: none; }
.vstudio-custom-sketchprev { display: flex; align-items: center; gap: 8px; border: 1px solid #E2E4EA; border-radius: 8px; background: #fff; padding: 6px 8px; }
.vstudio-custom-sketchimg { width: 34px; height: 34px; flex: 0 0 auto; border-radius: 6px; object-fit: cover; background: #F3F4F7; }
.vstudio-custom-sketchlbl { flex: 1; min-width: 0; font-size: 11.5px; font-weight: 600; color: #3B414C; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vstudio-custom-sketchrm { width: 22px; height: 22px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; border: none; background: none; color: #6B7280; cursor: pointer; border-radius: 6px; }
.vstudio-custom-sketchrm:hover { background: #FDEFEC; color: #C0492A; }
/* Concept "more info" viewer — read-only lightbox (scrim / X / Escape close). */
.vstudio-cinfo-overlay { position: fixed; inset: 0; z-index: 10050; background: rgba(23, 25, 35, 0.55); display: flex; align-items: center; justify-content: center; padding: 24px; }
.vstudio-cinfo { width: min(560px, 100%); max-height: min(80vh, 720px); display: flex; flex-direction: column; background: #fff; border-radius: 14px; box-shadow: 0 18px 50px rgba(20, 22, 40, 0.28); overflow: hidden; }
.vstudio-cinfo-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid #EEF0F4; }
.vstudio-cinfo-title { flex: 1; min-width: 0; font-size: 14px; font-weight: 700; color: #23262E; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vstudio-cinfo-body { padding: 14px 16px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.vstudio-cinfo-fig { display: flex; flex-direction: column; gap: 6px; }
.vstudio-cinfo-img { width: 100%; max-height: 46vh; object-fit: contain; border-radius: 10px; border: 1px solid #EEF0F4; background: #F7F8FA; }
.vstudio-cinfo-cap { font-size: 11px; font-weight: 600; color: #646B78; text-align: center; }
.vstudio-cinfo-lbl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: #646B78; }
.vstudio-cinfo-desc { font-size: 12.5px; line-height: 1.55; color: #3B414C; white-space: pre-wrap; word-break: break-word; }
.vstudio-cinfo-meta { font-size: 11px; color: #6B7280; }
/* ---- Brief mode switch (top of controls column) ----
 * Indigo accent for the active state so the current mode is unambiguous.
 * Inactive buttons stay muted; the contrast between the two is high.
 * min-height on both wrap and button is required: flex children without
 * intrinsic content height collapse to 0 in this layout (same bug we hit
 * on the segmented control). */
.vstudio-mode-switch {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-tertiary, #f0f1f5);
    padding: 3px;
    gap: 2px;
    margin-bottom: 8px;
    min-height: 42px;
    flex-shrink: 0;
}
.vstudio-mode-btn {
    flex: 1 1 auto;
    min-height: 36px;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary, #4b5563);   /* was #888 — too faint */
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    border-radius: 7px;
    transition: all 0.12s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    line-height: 1;
    user-select: none;
    /* Keep the label on a single line so "From URL", "Brief",
     * "Free-form" don't wrap when the left panel is at its narrowest
     * 320px floor. Without this, longer labels (e.g. localized
     * variants) could break across two lines. */
    white-space: nowrap;
}
.vstudio-mode-btn:hover {
    color: #4f46e5;
    background: rgba(99, 102, 241, 0.06);
}
.vstudio-mode-btn.active {
    background: #5B53E8;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.35);
}
.vstudio-mode-btn.active:hover {
    background: #5557e0;
    color: #fff;
}

/* ---- Brief panel ---- */
.vstudio-brief-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.vstudio-brief-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.vstudio-brief-input,
.vstudio-brief-select,
.vstudio-brief-textarea {
    width: 100%;
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
    font-family: inherit;
    background: #fff;
    outline: none;
    transition: border-color 0.12s;
}
.vstudio-brief-textarea {
    min-height: 64px;
    resize: vertical;
    line-height: 1.4;
}
.vstudio-brief-input:focus,
.vstudio-brief-select:focus,
.vstudio-brief-textarea:focus {
    border-color: #5B53E8;
    box-shadow: var(--focus-ring);
}
.vstudio-brief-input::placeholder,
.vstudio-brief-textarea::placeholder { color: var(--text-muted, #aaa); }

/* Source data panel — collapsible meta + JSON-LD shown after a URL scrape */
.vstudio-source-data-wrap:empty { display: none; }
.vstudio-source-data {
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 8px;
    background: #fafafb;
    font-size: 11px;
}
.vstudio-source-data > summary {
    list-style: none;
    cursor: pointer;
    padding: 8px 10px;
    font-weight: 600;
    color: var(--text-muted, #555);
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}
.vstudio-source-data > summary::-webkit-details-marker { display: none; }
.vstudio-source-data > summary::before {
    content: '▸';
    display: inline-block;
    transition: transform 0.15s;
    color: var(--text-muted, #888);
}
.vstudio-source-data[open] > summary::before { transform: rotate(90deg); }
.vstudio-source-meta-summary {
    margin-left: auto;
    font-weight: 400;
    color: var(--text-muted, #888);
    font-size: 10px;
}
.vstudio-source-badge {
    display: inline-block;
    padding: 1px 6px;
    background: #5B53E8;
    color: white;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.vstudio-source-body {
    padding: 0 10px 10px;
    border-top: 1px solid var(--border-subtle, #e6e6ec);
}
.vstudio-source-section { margin-top: 10px; }
.vstudio-source-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted, #888);
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}
.vstudio-source-row { display: flex; gap: 8px; padding: 2px 0; }
.vstudio-source-key {
    flex: 0 0 90px;
    color: var(--text-muted, #888);
    word-break: break-word;
}
.vstudio-source-val {
    flex: 1;
    color: #333;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.vstudio-source-ld-item {
    margin: 4px 0;
    border: 1px solid var(--border-subtle, #ececf0);
    border-radius: 6px;
    background: #fff;
}
.vstudio-source-ld-item > summary {
    cursor: pointer;
    padding: 6px 8px;
    list-style: none;
    user-select: none;
    color: #333;
}
.vstudio-source-ld-item > summary::-webkit-details-marker { display: none; }
.vstudio-source-pre {
    margin: 0;
    padding: 8px;
    background: #fafafb;
    border-top: 1px solid var(--border-subtle, #ececf0);
    font-size: 10px;
    line-height: 1.4;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    color: #555;
    max-height: 400px;
    overflow-y: auto;
}
.vstudio-source-empty {
    color: var(--text-muted, #aaa);
    font-style: italic;
    padding: 4px 0;
}

/* Free-form panel keeps the textarea look */
.vstudio-freeform-panel { display: flex; flex-direction: column; gap: 4px; }

/* URL panel — adds URL input on top, brief fields below (moved-in via JS) */
.vstudio-url-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.vstudio-url-row {
    display: flex;
    gap: 6px;
    align-items: stretch;
}
.vstudio-url-input { flex: 1; }
.vstudio-url-fetch-btn {
    flex-shrink: 0;
    background: linear-gradient(90deg, #f0f0ff 0%, #fff5f5 100%);
    border: 1px solid #c7c9f5;
    color: #4f46e5;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.vstudio-url-fetch-btn:hover {
    border-color: #5B53E8;
    background: linear-gradient(90deg, #e6e6ff 0%, #ffefef 100%);
}
.vstudio-url-fetch-btn:disabled { opacity: 0.6; cursor: wait; }

/* Shared fields container — same DOM moves between url panel + brief panel */
.vstudio-shared-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px dashed var(--border-subtle, #e6e6ec);
}
/* In Brief mode, the shared fields are the only content of briefPanel — drop the divider */
.vstudio-brief-panel > .vstudio-shared-fields {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

/* ---- Variant burst + Display Set buttons in tray ---- */
.vstudio-winner-burst,
.vstudio-winner-display-set {
    background: linear-gradient(90deg, #f0f0ff 0%, #fff5f5 100%);
    border: 1px solid #c7c9f5;
    color: #4f46e5;
    font-weight: 600;
}
.vstudio-winner-burst:hover,
.vstudio-winner-display-set:hover {
    border-color: #5B53E8;
    background: linear-gradient(90deg, #e6e6ff 0%, #ffefef 100%);
}

/* ---- Display Set picker modal ---- */
.vstudio-display-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}
.vstudio-display-modal {
    background: #fff;
    border-radius: 14px;
    padding: 24px 24px 0;        /* footer handles its own bottom padding */
    width: 720px;
    max-width: 100%;
    max-height: 90vh;
    /* Flex column so the sets grid scrolls and the footer stays pinned at
       the bottom — Generate stays visible regardless of scroll position. */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
}
.vstudio-display-sets-wrap {
    /* Wrapper around .vstudio-display-sets that scrolls when the size list
       overflows. .vstudio-display-sets stays a 2-col grid; this lets it
       scroll vertically while the modal header + footer stay put. */
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 12px;
}
.vstudio-display-modal h3 {
    margin: 0 0 4px;
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary, #1a1a2e);
}
.vstudio-display-sub {
    margin: 0 0 18px;
    font-size: 12px;
    color: var(--text-muted, #888);
    line-height: 1.5;
}
.vstudio-display-sets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    /* Scroll when many groups stack — the modal is flex-column so this is
       the area that shrinks while header + footer stay pinned. */
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 12px;
}
.vstudio-display-set-col {
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 10px;
    padding: 12px;
    background: #fafafd;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.vstudio-display-set-head {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.vstudio-display-set-head h4 {
    margin: 0;
    flex: 1;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary, #1a1a2e);
}
.vstudio-display-set-head .btn-sm { font-size: 10px; padding: 4px 8px; }
.vstudio-display-size-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
/* Sub-section label inside a preset column — used to mark the "Recently
   used" group at the top and the "All sizes" group below the divider so
   the user instantly understands why some rows float to the top. Compact,
   uppercase, low-contrast: it's a delimiter, not a heading. */
.vstudio-display-sub-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
    padding: 4px 8px 2px;
    margin-top: 2px;
}
.vstudio-display-sub-label:first-child { margin-top: 0; }
.vstudio-display-sub-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.06);
    margin: 4px 0;
}
.vstudio-display-size-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.1s;
    font-size: 12px;
}
.vstudio-display-size-row:hover { background: rgba(99,102,241,0.08); }
.vstudio-display-size-row input[type="checkbox"] {
    accent-color: #5B53E8;
    flex-shrink: 0;
}
/* Already-generated row — locked checkbox, dimmed, with a green "you have
   this" tint. Hover stays subtle so the user knows it's not interactive. */
.vstudio-display-size-row.is-existing {
    background: rgba(34, 197, 94, 0.06);
    cursor: not-allowed;
    opacity: 0.78;
}
.vstudio-display-size-row.is-existing:hover {
    background: rgba(34, 197, 94, 0.1);
}
.vstudio-display-size-row.is-existing input[type="checkbox"] {
    accent-color: #22c55e;
    cursor: not-allowed;
}
.vstudio-display-size-row.is-existing .vstudio-display-size-name {
    color: var(--text-secondary, #555);
}
.vstudio-display-size-row.is-existing .vstudio-display-size-dim {
    color: #16a34a;
}
.vstudio-display-size-name { flex: 1; color: var(--text-primary, #1a1a2e); }
.vstudio-display-size-dim { font-size: 10px; color: var(--text-muted, #888); font-family: ui-monospace, Menlo, monospace; }
.vstudio-display-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 -24px;             /* bleed to the modal edges so the bg covers full width */
    padding: 14px 24px;
    border-top: 1px solid var(--border-subtle, #e6e6ec);
    background: #fafafd;         /* slight contrast vs scrolling sets above */
    flex-shrink: 0;              /* footer never collapses */
}
.vstudio-display-count {
    flex: 1;
    font-size: 12px;
    color: var(--text-muted, #888);
}
/* Make the primary Generate button big + prominent. Was a tiny btn-sm at
   the bottom-right; now it's the visual anchor of the modal so the user
   never wonders "where do I confirm?". */
.vstudio-display-footer .btn-primary {
    padding: 10px 22px;
    font-size: 13px;
    font-weight: 600;
    min-width: 160px;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}
.vstudio-display-footer .btn-primary:disabled {
    box-shadow: none;
    opacity: 0.55;
}

/* "Recently used" column gets a soft highlight + indigo accent so it
   reads as a smart shortcut, not just another preset group. */
.vstudio-display-set-col.vstudio-display-recent-col {
    background: linear-gradient(135deg, #f0f2ff 0%, #fafafd 100%);
    border-color: #c7c9f5;
    grid-column: 1 / -1;          /* span both columns of the parent grid */
}
.vstudio-display-recent-col .vstudio-display-set-head h4 {
    color: #5B53E8;
}

.vstudio-optimize-row {
    display: flex;
    justify-content: flex-start;   /* small link, left-aligned (was a full-width button) */
    margin-top: -4px;
}
.vstudio-optimize-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    color: #8A86C8;
    font-size: 11.5px;
    font-weight: 600;
    padding: 3px 2px;
    cursor: pointer;
    transition: color 0.12s;
}
.vstudio-optimize-btn:hover {
    color: #5B53E8;
    background: none;
}

/* Brand kit selector + asset gallery */
.vstudio-brand-select {
    width: 100%;
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
    font-family: inherit;
    background: #fff;
    outline: none;
    cursor: pointer;
}
.vstudio-brand-select:focus { border-color: #5B53E8; }
.vstudio-brand-search {
    width: 100%;
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 8px;
    padding: 7px 10px;
    margin-bottom: 6px;
    font-size: 12px;
    font-family: inherit;
    background: #fff;
    outline: none;
}
.vstudio-brand-search:focus { border-color: #5B53E8; box-shadow: var(--focus-ring); }
.vstudio-brand-assets {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.vstudio-brand-assets:empty { display: none; }
.vstudio-brand-assets-label {
    font-size: 10px;
    color: var(--text-muted, #888);
    line-height: 1.4;
}
.vstudio-brand-empty {
    font-size: 11px;
    color: var(--text-muted, #aaa);
    padding: 6px 0;
    line-height: 1.4;
}
/* Brand-kit ASSET GALLERY grid. Renamed from .vstudio-brand-grid, which collided with the
   two-column Logo/Inspiration SLOT grid defined further down — the later rule won for both,
   so this gallery was silently laid out as 2 fixed columns instead of auto-filling at 70px. */
.vstudio-brand-assets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 6px;
}
.vstudio-brand-tile {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-subtle, #e6e6ec);
    background: #fafafd;
    cursor: pointer;
    padding: 0;
    transition: all 0.12s;
}
.vstudio-brand-tile:hover {
    border-color: #5B53E8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}
.vstudio-brand-tile img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    padding: 6px;
    box-sizing: border-box;
}
.vstudio-brand-tile.used {
    border-color: #5B53E8;
    background: #f0f0ff;
    cursor: default;
}
.vstudio-brand-tile.used::after {
    content: '✓';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 16px;
    height: 16px;
    background: #5B53E8;
    color: #fff;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.vstudio-brand-tile-label {
    position: absolute;
    inset: auto 0 0 0;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
    color: #fff;
    font-size: 9px;
    padding: 6px 4px 4px;
    text-align: center;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transition: opacity 0.12s;
}
.vstudio-brand-tile:hover .vstudio-brand-tile-label {
    opacity: 1;
}

/* ============================================================================
   COMPETITOR INSPIRATION PANEL — pulls saved-brand-kit Ad Library URLs and
   surfaces them as click-to-add reference cards. Hidden when the active kit
   has no competitors.
   ============================================================================ */
.vstudio-inspiration {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}
.vstudio-inspiration:empty { display: none; }
.vstudio-inspiration-desc {
    font-size: 10.5px;
    color: var(--text-muted, #888);
    line-height: 1.45;
    margin: -2px 0 4px;
}
.vstudio-inspiration-block {
    background: #fafafd;
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 8px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.vstudio-inspiration-head {
    display: flex;
    align-items: center;
    gap: 8px;
}
.vstudio-inspiration-name {
    flex: 1;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary, #1a1a2e);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.vstudio-inspiration-refresh {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    font-size: 10.5px;
    font-weight: 600;
    color: #1a1a2e;
    background: #fff;
    border: 1px solid #d4d4e0;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.12s;
}
.vstudio-inspiration-refresh:hover {
    border-color: #5B53E8;
    color: #5B53E8;
}
.vstudio-inspiration-refresh:disabled { opacity: 0.5; cursor: progress; }

/* Sort dropdown — narrow, same compact look as the refresh button.
   Sits between the competitor name and the refresh action so all
   per-block controls stack on one row. */
.vstudio-inspiration-sort {
    padding: 3px 6px;
    font-size: 10.5px;
    font-weight: 600;
    color: #1a1a2e;
    background: #fff;
    border: 1px solid #d4d4e0;
    border-radius: 14px;
    cursor: pointer;
    outline: none;
    font-family: inherit;
    max-width: 130px;
}
.vstudio-inspiration-sort:hover  { border-color: #5B53E8; color: #5B53E8; }
.vstudio-inspiration-sort:focus  { border-color: #5B53E8; box-shadow: 0 0 0 2px rgba(99,102,241,0.15); }

.vstudio-inspiration-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
    gap: 6px;
}
.vstudio-inspiration-grid:empty { display: none; }
.vstudio-inspiration-card {
    position: relative;
    aspect-ratio: 1;
    border-radius: 7px;
    overflow: hidden;
    border: 1px solid var(--border-subtle, #e6e6ec);
    background: #fff;
    cursor: pointer;
    transition: all 0.12s;
}
.vstudio-inspiration-card:hover {
    border-color: #5B53E8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.18);
}
.vstudio-inspiration-card.is-loading {
    opacity: 0.5;
    cursor: progress;
}
.vstudio-inspiration-card.used {
    border-color: #5B53E8;
    background: #f0f0ff;
    cursor: default;
}
.vstudio-inspiration-card.used::after {
    content: '✓ added';
    position: absolute;
    inset: 4px 4px auto auto;
    background: #5B53E8;
    color: #fff;
    font-size: 8.5px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 8px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.vstudio-inspiration-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #fafafd;
}

/* "Running N days" badge — top-left. >=30d gets a hot color so the
   user's eye gravitates to long-runners (the "likely converting" signal). */
.vstudio-inspiration-days {
    position: absolute;
    top: 4px;
    left: 4px;
    background: rgba(26, 26, 46, 0.86);
    color: #fff;
    font-size: 9.5px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}
.vstudio-inspiration-days-hot {
    background: #ef4444;          /* red — long-running winners (≥30d) */
}
.vstudio-inspiration-days-new {
    background: #10b981;          /* green — brand-new launches (≤3d) */
}

/* "View" link — small, bottom-left, opens the Ad Library entry */
.vstudio-inspiration-view {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(255, 255, 255, 0.92);
    color: #1a1a2e;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 8px;
    text-decoration: none;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0;
    transition: opacity 0.12s;
}
.vstudio-inspiration-card:hover .vstudio-inspiration-view {
    opacity: 1;
}
.vstudio-inspiration-view:hover { background: #fff; color: #5B53E8; }

.vstudio-inspiration-status {
    font-size: 10.5px;
    color: var(--text-muted, #555);
    line-height: 1.45;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.vstudio-inspiration-status:empty { display: none; }

/* Loaded-state summary line — sits above the Browse button. */
.vstudio-inspiration-summary {
    font-size: 11px;
    color: #4a4a6a;
    font-weight: 500;
}

/* "Browse N ads →" primary button — opens the popup picker. */
.vstudio-inspiration-browse {
    align-self: flex-start;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 700;
    background: #1a1a2e;
    color: #fff;
    border: 1px solid #1a1a2e;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: all 0.12s;
}
.vstudio-inspiration-browse:hover {
    background: #0e0e1f;
    border-color: #0e0e1f;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26, 26, 46, 0.15);
}

/* "Get inspiration from all competitors" button — top-level CTA that
   sits between the description and the per-competitor blocks. Solid
   indigo so it reads as the primary affordance when 2+ competitors
   exist (vs. the dark per-block Browse button below). */
.vstudio-inspiration-all-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}
.vstudio-inspiration-all-btn {
    align-self: flex-start;
    padding: 8px 14px;
    background: #5B53E8;
    color: #fff;
    border: 1px solid #5B53E8;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: all 0.12s;
}
.vstudio-inspiration-all-btn:hover {
    background: #4f46e5;
    border-color: #4f46e5;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}
.vstudio-inspiration-all-btn:disabled,
.vstudio-inspiration-all-btn.is-loading {
    opacity: 0.85;
    cursor: progress;
    transform: none;
    /* Indigo wash + animated stripes so the disabled state reads as
       "actively working" rather than just "greyed out". */
    background: linear-gradient(135deg, #5B53E8 0%, #4f46e5 100%);
    border-color: #4f46e5;
}
.vstudio-inspiration-all-progress {
    font-size: 10.5px;
    color: var(--text-muted, #6e6e8a);
    font-style: italic;
    min-height: 14px;       /* reserve space so layout doesn't jump */
}

/* Spinner animation — swapped in for the star icon while loading.
   Uses an SVG circle with a stroke arc that rotates continuously. */
.vstudio-insp-spinner {
    animation: vstudio-insp-spin 0.9s linear infinite;
    transform-origin: 50% 50%;
}
@keyframes vstudio-insp-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* Sort dropdown placement inside the picker header. */
.vstudio-refpick-sort {
    margin-left: auto;
    margin-right: 8px;
}
.vstudio-refpick-compfilter {
    margin-left: auto;
    margin-right: 4px;
}
/* When BOTH filter + sort are in the header, drop the auto margin
   from the sort so they sit side-by-side instead of pushing apart. */
.vstudio-refpick-compfilter ~ .vstudio-refpick-sort {
    margin-left: 0;
}

/* Competitor pill on tile — surfaces in multi-competitor combined view.
   Top-center, indigo background, white text. Always visible (not on
   hover) because "which competitor is this from?" is critical info
   the user needs to read before deciding to add the ad as reference. */
.vstudio-inspiration-comp-pill {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(79, 70, 229, 0.92);
    color: #fff;
    font-size: 9.5px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 10px;
    letter-spacing: 0.03em;
    max-width: calc(100% - 80px);   /* leave room for View link + check */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    z-index: 2;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

/* "View" link on inspiration tiles inside the picker. Top-left,
   surfaces on hover so it doesn't compete with the selection
   check-mark badge. */
.vstudio-inspiration-tile .vstudio-refpick-view {
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(255,255,255,0.92);
    color: #1a1a2e;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 8px;
    text-decoration: none;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0;
    transition: opacity 0.12s;
    z-index: 2;
}
.vstudio-inspiration-tile:hover .vstudio-refpick-view {
    opacity: 1;
}
.vstudio-inspiration-tile .vstudio-refpick-view:hover {
    background: #fff;
    color: #5B53E8;
}

/* Days-active badge inside picker tile — bottom-left.
   CRITICAL: explicitly reset `top` to auto. The base
   `.vstudio-inspiration-days` rule sets `top: 4px`, so without this
   override BOTH top and bottom would be active, stretching the badge
   to ~100% height of the tile (the "visual bug" the user reported). */
.vstudio-inspiration-tile .vstudio-inspiration-days {
    position: absolute;
    top: auto;
    bottom: 8px;
    left: 8px;
    right: auto;
    height: auto;       /* defensive: kill any inherited height */
    z-index: 2;
}

/* Disabled state — for image_urls already in state.referenceImages,
   we dim the tile + block clicks. The selected check-mark won't show. */
.vstudio-inspiration-tile.is-disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.vstudio-inspiration-tile.is-disabled::before {
    content: 'Already added';
    position: absolute;
    inset: auto 0 0 0;
    background: rgba(0,0,0,0.7);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    text-align: center;
    padding: 4px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    z-index: 3;
}

/* Callout for known-flaky search URLs. Amber tint so the eye lands
   on it as "warning + action needed", not a hard error. */
.vstudio-inspiration-callout {
    padding: 8px 10px;
    background: linear-gradient(135deg, #fffbeb 0%, #fff 100%);
    border: 1px solid #fde68a;
    border-radius: 7px;
    color: #78350f;
    font-size: 10.5px;
    line-height: 1.5;
    margin-bottom: 6px;
}
.vstudio-inspiration-callout strong { color: #92400e; font-weight: 700; }

/* Diagnostic toggle + table — surfaced when 0 ads parsed. Tells the
   user "did the scrape fail, did Meta block us, or did our parser
   miss the data?" without us needing to ask for raw HTML. */
.vstudio-inspiration-diag-toggle {
    margin-top: 6px;
    background: none;
    border: none;
    color: #5B53E8;
    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}
.vstudio-inspiration-diag-toggle:hover { color: #4f46e5; }
.vstudio-inspiration-diag {
    margin-top: 8px;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 6px;
    font-size: 10.5px;
}
.vstudio-inspiration-diag-tbl {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}
.vstudio-inspiration-diag-tbl th,
.vstudio-inspiration-diag-tbl td {
    padding: 3px 6px;
    text-align: left;
    border-bottom: 1px dashed #ececf3;
    font-weight: 500;
    color: #1a1a2e;
}
.vstudio-inspiration-diag-tbl th {
    color: #6e6e8a;
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    width: 50%;
}
.vstudio-inspiration-diag-lbl {
    margin-top: 8px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6e6e8a;
}
.vstudio-inspiration-diag-pre {
    margin: 4px 0 0;
    padding: 6px;
    background: #fafafd;
    border: 1px solid #ececf3;
    border-radius: 4px;
    font-size: 10px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 110px;
    overflow: auto;
    color: #1a1a2e;
}
.vstudio-inspiration-diag-attempts {
    margin: 4px 0 0;
    padding: 0 0 0 18px;
    font-size: 10.5px;
    color: #4a4a6a;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

/* Reference images uploader */
.vstudio-refs {
    /* No box — border + background removed per request. The drag-over state below
       still flashes a border so drop feedback survives. */
    border-radius: 10px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.12s ease, background 0.12s ease;
}
/* Active drag-over state — switch border to indigo + softer tint so
   the user knows the area accepts the drop. Applied while a file
   drag passes over the wrap. */
.vstudio-refs.is-drag-active {
    border-color: #5B53E8;
    border-style: dashed;
    background: rgba(99, 102, 241, 0.06);
}
/* In-flight upload (drop/paste) — dim slightly so the user sees the
   upload is processing. Wraps remain interactive (no pointer-events
   block) so additional drops can stack into the same batch. */
.vstudio-refs.is-uploading {
    opacity: 0.7;
}
.vstudio-refs-hint {
    font-size: 11px;
    color: var(--text-muted, #888);
    text-align: center;
    line-height: 1.4;
    padding: 6px 4px;
}
/* Reference SLOTS — Logo · Products · Inspiration, stacked vertically. Each
   slot is a labeled box; its body wraps tiles (≥90px) + an add affordance. */
.vstudio-refs-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
/* Reference & guidance design: helper line under the product grid + the
   "Brand assets" section label above the Logo/Inspiration pair. */
.vstudio-ref-help { font-size: 11px; color: var(--text-muted, #6B7280); line-height: 1.45; margin-top: -2px; }
.vstudio-ref-assets-label { font-size: 10.5px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-secondary, #4b5563); margin-top: 4px; }

/* Reference & guidance design — product-reference grid + brand-asset slots. */
.vstudio-pref-head { display: flex; align-items: center; gap: 7px; }
.vstudio-pref-head-label { font-size: 11px; font-weight: 700; letter-spacing: .04em; color: #646B78; text-transform: uppercase; }
.vstudio-pref-head-count { font-size: 11px; color: #646B78; }
.vstudio-pref-grid { margin-top: 7px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.vstudio-pref-tile { position: relative; aspect-ratio: 1 / 1; border-radius: 9px; overflow: visible; border: 1px solid #ECEDF1; background: #FAFAFC; }
.vstudio-pref-tile img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 8px; }
.vstudio-pref-rm { position: absolute; top: -5px; right: -5px; width: 18px; height: 18px; border-radius: 50%; background: #14171F; color: #fff; border: 2px solid #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.vstudio-pref-add { aspect-ratio: 1 / 1; border: 1.5px dashed #D5D8DF; background: #FBFBFC; border-radius: 9px; display: flex; align-items: center; justify-content: center; color: #6B7280; cursor: pointer; }
.vstudio-pref-add:hover { border-color: #5B53E8; color: #5B53E8; background: #F8F7FE; }
.vstudio-pref-help { margin-top: 8px; font-size: 11px; color: #6B7280; line-height: 1.45; }
.vstudio-brand-label { margin-top: 14px; font-size: 11px; font-weight: 700; letter-spacing: .04em; color: #646B78; text-transform: uppercase; }
.vstudio-brand-grid { margin-top: 7px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vstudio-brand-slot { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border: 1.5px dashed #D5D8DF; background: #FBFBFC; border-radius: 10px; padding: 15px 8px; cursor: pointer; }
.vstudio-brand-slot:hover { border-color: #5B53E8; background: #F8F7FE; }
.vstudio-brand-slot.is-filled { border-style: solid; border-color: #DDE2FB; background: #F4F6FF; }
/* Drag-hover on a single-image brand slot (Logo / Inspiration). Without a visible
   target these slots read as non-droppable — which they were, until the slot got its
   own drop handler; files used to bubble to the refs wrap and land as products. */
.vstudio-brand-slot.is-drag-active { border-color: #5B53E8; border-style: dashed; background: rgba(99, 102, 241, 0.07); }
.vstudio-brand-thumb { width: 30px; height: 30px; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #fff; }
.vstudio-brand-thumb img { width: 100%; height: 100%; object-fit: contain; }
.vstudio-brand-plus { color: #6B7280; display: flex; }
.vstudio-brand-name { font-size: 11px; font-weight: 600; color: #6B7280; }
.vstudio-brand-name.is-filled { color: #5B53E8; }
.vstudio-brand-rm { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; background: #14171F; color: #fff; border: 2px solid #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
/* Logo + Inspiration share ONE row (each holds max 1 image) to save vertical
   space; References (unlimited) stays full width below. Each paired slot fills
   half the row and its single tile / add-button fills the slot width. */
.vstudio-ref-pair {
    display: flex;
    gap: 10px;
    align-items: start;
}
.vstudio-ref-pair > .vstudio-ref-slot { flex: 1 1 0; min-width: 0; }
.vstudio-ref-pair .vstudio-ref-slot-body { display: block; }
.vstudio-ref-pair .vstudio-ref-tile,
.vstudio-ref-pair .vstudio-ref-slot-add { width: 100%; }
.vstudio-ref-pair .vstudio-ref-slot-add { aspect-ratio: 1 / 1; height: auto; }
.vstudio-ref-slot {
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 10px;
    padding: 8px 10px 10px;
    background: #fff;
    transition: border-color 0.12s, background 0.12s;
}
.vstudio-ref-slot.is-drag-active { border-color: #5B53E8; border-style: dashed; background: rgba(99, 102, 241, 0.05); }
.vstudio-ref-slot.is-logo        { border-left: 3px solid #5B53E8; }
.vstudio-ref-slot.is-product     { border-left: 3px solid #10b981; }
.vstudio-ref-slot.is-inspiration { border-left: 3px solid #f59e0b; }
.vstudio-ref-slot-label {
    display: flex; align-items: center; gap: 6px;
    font-size: 10.5px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase;
    color: var(--text-secondary, #4b5563);
    margin-bottom: 6px;
}
.vstudio-ref-slot-max {
    font-size: 9.5px; font-weight: 700; color: #646B78;
    background: #f3f4f6; border-radius: 999px; padding: 1px 6px;
}
.vstudio-ref-slot-body { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
/* References (multi) slot — always ≥4 per row (3 images + the add button) no
   matter how narrow the panel gets. Tiles/add fill the grid cell. Logo +
   Inspiration stay single-tile flex (1 max each). */
.vstudio-ref-slot.is-product .vstudio-ref-slot-body {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    align-items: start;
}
.vstudio-ref-slot.is-product .vstudio-ref-tile,
.vstudio-ref-slot.is-product .vstudio-ref-slot-add { width: 100%; }
.vstudio-ref-slot-add {
    width: 90px; aspect-ratio: 1 / 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    border: 1.5px dashed var(--border, #d8dae5); border-radius: 8px;
    background: #fafbff; color: var(--text-muted, #9ca3af);
    font-size: 11px; font-weight: 600; cursor: pointer; font-family: inherit;
    transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.vstudio-ref-slot-add:hover { border-color: #5B53E8; color: #5B53E8; background: #f5f6ff; }
.vstudio-ref-slot-add-plus { font-size: 20px; font-weight: 400; line-height: 1; }
.vstudio-ref-tile {
    position: relative;
    width: 90px;
    flex: 0 0 auto;
}
/* Per-tile role switcher (Logo / Products / Inspiration) — lets the user re-tag
   any reference (incl. Meta Ads Library images) in place. */
.vstudio-ref-role {
    width: 100%;
    margin-top: 5px;
    font-size: 11px;
    font-family: inherit;
    padding: 3px 4px;
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 6px;
    background: #fff;
    color: var(--text-primary, #1a1a2e);
    cursor: pointer;
}
.vstudio-ref-role:focus { outline: none; border-color: var(--accent, #5B53E8); }
/* Square image holder — ~30% bigger than the old 56px fixed tile (the grid
   column drives the actual width; aspect-ratio keeps it square). The remove
   button + outlines attach here so the under-image label stays clean. */
.vstudio-ref-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-subtle, #e6e6ec);
    background: #fff;
}
.vstudio-ref-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.vstudio-ref-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.12s;
}
.vstudio-ref-remove:hover { background: rgba(239, 68, 68, 0.9); }
.vstudio-refs-upload {
    align-self: flex-start;
}

/* Banner shown above the model picker when refs are uploaded */
.vstudio-refs-banner {
    background: #f0f0ff;
    border: 1px solid #c7c9f5;
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 8px;
}
.vstudio-refs-banner-title {
    font-size: 12px;
    font-weight: 600;
    color: #4f46e5;
}
.vstudio-refs-banner-sub {
    font-size: 11px;
    color: var(--text-muted, #888);
    margin-top: 2px;
    line-height: 1.4;
}

/* Optimizer popover — extra styles for the side-by-side diff */
.vstudio-optimized-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted, #888);
    margin: 8px 0 2px;
}
.vstudio-optimized-body.subtle {
    background: #fafafa;
    color: var(--text-muted, #888);
    font-size: 11px;
}
.vstudio-optimized-actions {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    justify-content: flex-end;
}
.vstudio-optimized-stamp {
    margin-top: 10px;
    padding-top: 6px;
    border-top: 1px dashed var(--border-subtle, #e6e6ec);
    font-size: 9px;
    color: var(--text-muted, #aaa);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.02em;
    text-align: right;
}

.vstudio-prompt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}
.vstudio-prompt-header .vstudio-label {
    margin-bottom: 0;
}
.vstudio-optimizer-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px 3px 6px;
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 999px;
    background: #fff;
    cursor: pointer;
    font-size: 11px;
    color: var(--text-muted, #888);
    user-select: none;
    transition: all 0.12s;
}
.vstudio-optimizer-toggle:hover {
    border-color: #5B53E8;
}
.vstudio-optimizer-toggle.on {
    border-color: #5B53E8;
    background: #f0f0ff;
    color: #4f46e5;
}
.vstudio-optimizer-toggle input[type="checkbox"] {
    accent-color: #5B53E8;
    margin: 0;
    width: 12px;
    height: 12px;
}
.vstudio-optimizer-pill {
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1;
}
.vstudio-optimizer-peek {
    background: transparent;
    border: none;
    color: inherit;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    margin-left: 2px;
    opacity: 0.7;
}
.vstudio-optimizer-peek:hover { opacity: 1; }

.vstudio-optimized-popover {
    position: fixed;
    z-index: 9999;
    background: #fff;
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    padding: 14px 16px;
    width: 360px;
    max-width: calc(100vw - 24px);
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-primary, #1a1a2e);
}
.vstudio-optimized-popover h4 {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted, #888);
}
.vstudio-optimized-popover .vstudio-optimized-body {
    background: #fafafd;
    border-radius: 6px;
    padding: 10px 12px;
    margin: 6px 0 10px;
    color: var(--text-primary, #1a1a2e);
    white-space: pre-wrap;
    word-wrap: break-word;
}
.vstudio-optimized-popover .vstudio-optimized-meta {
    font-size: 11px;
    color: var(--text-muted, #888);
    margin-top: 6px;
}

.vstudio-prompt {
    width: 100%;
    min-height: 120px;
    padding: 10px 12px;
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    outline: none;
    transition: border-color 0.15s;
}
.vstudio-prompt:focus {
    border-color: #5B53E8;
    box-shadow: var(--focus-ring);
}

.vstudio-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.vstudio-chip {
    padding: 6px 12px;
    min-height: 28px;
    line-height: 1;
    font-size: 12px;
    border-radius: 999px;
    border: 1px solid var(--border-subtle, #e6e6ec);
    background: #fff;
    color: var(--text-secondary, #555);
    cursor: pointer;
    transition: all 0.12s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.vstudio-chip:hover { border-color: #5B53E8; color: #5B53E8; }
.vstudio-chip.active {
    background: #5B53E8;
    color: #fff;
    border-color: #5B53E8;
}

/* Concepts multi-select panel — sits between the Style chips and the
   Text-overlay toggle in the Studio left column. Closed by default;
   user opens via the toggle button next to the section label. */
.vstudio-concepts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 10px;
    margin-bottom: 4px;
}
.vstudio-concepts-toggle {
    background: transparent;
    border: 1px solid var(--border-subtle, #e6e6ec);
    color: var(--text-secondary, #555);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.12s;
    line-height: 1.2;
}
.vstudio-concepts-toggle:hover {
    border-color: #5B53E8;
    color: #5B53E8;
}
.vstudio-concepts-hint {
    font-size: 11px;
    color: var(--text-muted, #9ca3af);
    line-height: 1.4;
    margin-bottom: 6px;
}
.vstudio-concepts-panel {
    /* No wrapper background / border / padding — the concept groups sit flush
       (per request). Just the bottom gap before the next control. */
    margin-bottom: 6px;
}
.vstudio-concepts-actions {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}
.vstudio-concepts-action {
    flex: 0 0 auto;
    padding: 6px 13px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    border: 1px solid #c7c9f5;
    background: #eef2ff;
    color: #4338ca;
    cursor: pointer;
    transition: all 0.12s;
}
.vstudio-concepts-action:hover {
    border-color: #5B53E8;
    background: #5B53E8;
    color: #fff;
}
/* Collapsible concept-tier groups — single-open accordion (click to toggle). */
.vstudio-concepts-group {
    border: 1px solid #ECEDF1;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 7px;
}
.vstudio-concepts-group:last-child {
    margin-bottom: 0;
}
.vstudio-concepts-group-head {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 9px;
    background: none;       /* flat — no category fill (per request) */
    border: none;
    cursor: pointer;
    padding: 8px 10px;      /* trimmed extra padding */
    text-align: left;
    font-family: inherit;
}
.vstudio-concepts-group-head:hover { background: #F4F5F7; }
.vstudio-concepts-group-title {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    font-weight: 700;
    color: #3B414C;
}
.vstudio-concepts-group-chev { flex: 0 0 auto; display: flex; transition: transform .15s; }
.vstudio-concepts-group.is-open .vstudio-concepts-group-chev { transform: rotate(180deg); }
.vstudio-concepts-tier-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1.2;
}
.vstudio-concepts-tier-badge.tier-1 {
    background: #5B53E8;
    color: #ffffff;
}
.vstudio-concepts-tier-badge.tier-2 {
    background: rgba(99, 102, 241, 0.12);
    color: #5B53E8;
}
.vstudio-concepts-tier-badge.tier-3 {
    background: var(--bg, #f3f4f6);
    color: var(--text-muted, #6b7280);
}
.vstudio-concepts-list {
    padding: 4px;
    flex-direction: column;
    gap: 1px;
    display: none;   /* collapsed by default; .is-open reveals it */
}
.vstudio-concepts-group.is-open .vstudio-concepts-list { display: flex; }
.vstudio-concept-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    transition: all 0.12s;
}
.vstudio-concept-row:hover {
    border-color: var(--border-subtle, #e6e6ec);
    background: var(--bg-hover, #f9fafb);
}
.vstudio-concept-row.on {
    border-color: #5B53E8;
    background: rgba(99, 102, 241, 0.06);
}
.vstudio-concept-row > input[type="checkbox"] {
    margin-top: 2px;
    flex-shrink: 0;
}
.vstudio-concept-row-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.vstudio-concept-row-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text, #1f2937);
    line-height: 1.3;
}
.vstudio-concept-row-sub {
    font-size: 10px;
    color: var(--text-muted, #6b7280);
    line-height: 1.3;
}

/* Mini concept thumbnail (in front of each row). Hover the row >1s for the
   larger floating preview below. */
.vstudio-concept-thumb {
    flex-shrink: 0;
    width: 38px;
    height: 30px;
    margin-top: 1px;
    border-radius: 5px;
    object-fit: cover;
    background: var(--bg-subtle, #f1f1f4);
    border: 1px solid var(--border-subtle, #e6e6ec);
    display: block;
}
.vstudio-concept-row.on .vstudio-concept-thumb {
    border-color: #5B53E8;
}

/* Floating >1s-dwell preview popup. position:fixed + JS-computed left/top so
   it anchors beside the hovered row and never clips in the narrow column. */
.vstudio-concept-preview-pop {
    position: fixed;
    z-index: 9000;
    width: 260px;
    padding: 5px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid var(--border-subtle, #e6e6ec);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.22);
    opacity: 0;
    transform: scale(0.97);
    transition: opacity 0.12s ease, transform 0.12s ease;
    pointer-events: none;
}
.vstudio-concept-preview-pop.visible {
    opacity: 1;
    transform: scale(1);
}
.vstudio-concept-preview-img {
    display: block;
    width: 100%;
    border-radius: 6px;
}

/* ---------- Saved concept groups (popover + modal) ----------
   The "Groups (N) ▾" button sits in `.vstudio-concepts-actions`
   between the "Last selected" pill and the "Clear all" pill. Its
   wrapper is relative-positioned so the popover anchors under it.

   UX split:
   - Popover = quick LOAD list. Hover a row to reveal its × delete
     button (kept out of the resting view to avoid a wall of icons).
   - Modal   = name + chip-preview + save. Pulled out so naming a new
     group gets focused attention instead of cramping the popover. */
.vstudio-concepts-groups-wrap {
    /* No longer a positioning context — the popover is `position: fixed`
       and computes its location from `groupsBtn.getBoundingClientRect()`
       at open-time. Was `position: relative` previously, which made the
       popover `position: absolute` and got it CLIPPED by the parent
       sidebar's `overflow-y: auto` (`.vstudio-controls`). Fixed
       positioning anchors to the viewport instead, escaping the clip. */
    display: inline-flex;
}
.vstudio-concepts-groups-popover {
    position: fixed;
    /* top/left assigned by JS at open-time via getBoundingClientRect.
       z above modal-overlay (1000) would over-stack the save modal —
       keep it under the modal but above app chrome. */
    z-index: 900;
    min-width: 260px;
    max-width: 340px;
    background: #fff;
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(15, 17, 26, 0.12);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 0;
}
.vstudio-concepts-groups-empty {
    text-align: left;
    padding: 12px 8px;
}
.vstudio-concepts-groups-empty-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text, #1f2937);
    margin-bottom: 4px;
}
.vstudio-concepts-groups-empty-sub {
    font-size: 11px;
    color: var(--text-muted, #6b7280);
    line-height: 1.4;
}
.vstudio-concepts-groups-list {
    display: flex;
    flex-direction: column;
    /* 5px gap = visible separation between rows without breaking the
       compact popover feel. Pre-redesign was 2px and groups visually
       bled into each other. */
    gap: 5px;
    /* Cap list height so 50 saved groups don't fall off the viewport.
       Internal scroll keeps the footer CTA always reachable. */
    max-height: 280px;
    overflow-y: auto;
    padding: 2px 4px 2px 2px;
}
/* Each group is now a self-contained CARD: subtle muted background,
   1px hairline border, rounded corners. Hover lifts the card with
   an indigo border + tinted background. The whole card is the
   visual unit — load button stripped of its own border/bg so the
   card frame reads clean. */
.vstudio-concepts-group-item {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 0;
    background: var(--bg-muted, #fafafb);
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 7px;
    overflow: hidden;
    transition: background-color 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.vstudio-concepts-group-item:hover {
    background: rgba(99, 102, 241, 0.06);
    border-color: rgba(99, 102, 241, 0.45);
    box-shadow: 0 1px 3px rgba(99, 102, 241, 0.08);
}
.vstudio-concepts-group-load {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    /* Slightly more vertical padding than before (8/12 vs 7/10) so
       the card has breathing room for the divider effect to read. */
    padding: 9px 12px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--text, #1f2937);
    cursor: pointer;
    font-size: 12.5px;
    text-align: left;
    transition: color 0.12s;
    min-width: 0;
}
.vstudio-concepts-group-item:hover .vstudio-concepts-group-load {
    color: #4338ca;
}
.vstudio-concepts-group-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}
.vstudio-concepts-group-count {
    flex: 0 0 auto;
    font-size: 10px;
    font-weight: 700;
    color: #5B53E8;
    background: rgba(99, 102, 241, 0.12);
    padding: 2px 7px;
    border-radius: 999px;
    line-height: 1.4;
}
/* Hover-reveal delete. Resting state: invisible + not interactive
   (so it can't steal a click before the user sees it appear). Hover
   on the ROW (not just the button) brings it in. Keyboard-focused
   delete buttons also stay visible for accessibility.

   Lives INSIDE the card frame now — borderless on the outside, but
   gains a left-side hairline divider on hover that visually separates
   it from the load button. The whole card has `overflow: hidden` so
   the delete button respects the card's rounded corners. */
.vstudio-concepts-group-delete {
    flex: 0 0 auto;
    width: 30px;
    padding: 0;
    border: none;
    border-left: 1px solid transparent;
    border-radius: 0;
    background: transparent;
    color: var(--text-muted, #9ca3af);
    cursor: pointer;
    font-size: 17px;
    line-height: 1;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s, color 0.12s, background-color 0.12s, border-color 0.12s;
}
.vstudio-concepts-group-item:hover .vstudio-concepts-group-delete,
.vstudio-concepts-group-item:focus-within .vstudio-concepts-group-delete,
.vstudio-concepts-group-delete:focus-visible {
    opacity: 1;
    pointer-events: auto;
    border-left-color: rgba(99, 102, 241, 0.25);
}
.vstudio-concepts-group-delete:hover {
    color: #dc2626;
    background: #fef2f2;
    border-left-color: #fca5a5;
}
.vstudio-concepts-groups-footer {
    margin-top: 4px;
    padding: 4px 2px 0;
    border-top: 1px solid var(--border-subtle, #e6e6ec);
}
.vstudio-concepts-groups-save-cta {
    width: 100%;
    padding: 8px 10px;
    border: 1px dashed var(--border-subtle, #d1d5db);
    border-radius: 6px;
    background: #fff;
    color: var(--text-secondary, #4b5563);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    transition: all 0.12s;
}
.vstudio-concepts-groups-save-cta:hover:not(.is-disabled) {
    border-color: #5B53E8;
    border-style: solid;
    color: #5B53E8;
    background: rgba(99, 102, 241, 0.04);
}
.vstudio-concepts-groups-save-cta.is-disabled,
.vstudio-concepts-groups-save-cta:disabled {
    color: var(--text-muted, #9ca3af);
    cursor: not-allowed;
    opacity: 0.7;
}

/* ---------- Save-group modal ---------- */
.vstudio-savegroup-overlay {
    /* Inherits base from `.modal-overlay`. Bump z so it stacks above
       the popover (popover has z-index:50). */
    z-index: 1000;
}
.vstudio-savegroup-modal {
    width: min(440px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    padding: 18px 20px 16px;
}
.vstudio-savegroup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}
.vstudio-savegroup-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text, #1f2937);
    margin: 0;
}
.vstudio-savegroup-sub {
    font-size: 12px;
    color: var(--text-muted, #6b7280);
    line-height: 1.4;
    margin: 0 0 14px;
}
.vstudio-savegroup-chips-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #4b5563);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}
.vstudio-savegroup-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    background: var(--bg-muted, #fafafb);
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 6px;
    margin-bottom: 14px;
    max-height: 120px;
    overflow-y: auto;
}
.vstudio-savegroup-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.10);
    color: #4338ca;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
}
.vstudio-savegroup-name-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}
.vstudio-savegroup-name-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #4b5563);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.vstudio-savegroup-name-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 6px;
    font-size: 14px;
    color: var(--text, #1f2937);
    background: #fff;
    transition: border-color 0.12s, box-shadow 0.12s;
}
.vstudio-savegroup-name-input:focus {
    outline: none;
    border-color: #5B53E8;
    box-shadow: var(--focus-ring);
}
.vstudio-savegroup-name-input.is-invalid {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}
.vstudio-savegroup-overwrite-note {
    font-size: 11px;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 6px;
    padding: 7px 10px;
    margin-bottom: 12px;
    line-height: 1.4;
}
.vstudio-savegroup-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}

.vstudio-segmented {
    display: flex;
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 8px;
    background: var(--bg-tertiary, #f0f1f5);
    padding: 3px;
    gap: 2px;
    align-items: stretch;
    min-height: 38px;
}
.vstudio-seg-btn {
    flex: 1 1 auto;
    min-height: 32px;
    line-height: 1;
    padding: 7px 10px;
    border: none;
    background: transparent;
    color: var(--text-secondary, #555);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.12s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.vstudio-seg-btn:hover { color: #5B53E8; }
.vstudio-seg-btn.active {
    background: #fff;
    color: #1a1a2e;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
/* Disabled — used by the variants picker when the selected model(s)
   cap below the offered button (e.g. clicking "6" with a maxVariants:4
   model). The button stays in place (so the user can see WHAT they
   can't pick) but reads as inert: muted text, no hover lift,
   crossed-out cursor. Tooltip explains why via the `title` attr. */
.vstudio-seg-btn:disabled,
.vstudio-seg-btn-disabled {
    /* Readable but clearly inert (2026-11-08): the old white-at-25% label was
       invisible on the light segmented track. #6B7280 on the #f0f0f2 track is
       ~4.4:1 (≥3:1 for the label); the dashed inset + strike-through carry the
       "can't pick" signal without relying on colour alone. */
    color: #6B7280;
    background: transparent;
    cursor: not-allowed;
    text-decoration: line-through;
    text-decoration-color: #9CA3AF;
    text-decoration-thickness: 1px;
    outline: 1px dashed #C4C7CF;
    outline-offset: -3px;
}
.vstudio-seg-btn:disabled:hover,
.vstudio-seg-btn-disabled:hover {
    color: #6B7280;
    background: transparent;
}

/* Models panel — collapsible <details> wrapper so the picker is hidden
   by default. Visual language matches .vstudio-source-data above:
   rotating chevron, hover tint, and a subtle border that reads as a
   group instead of competing with the brief panel below it. */
.vstudio-models-details {
    margin: 0 0 8px 0;
}
.vstudio-models-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--border-subtle, #e6e6ec);
    cursor: pointer;
    list-style: none;
    user-select: none;
    transition: background 0.12s, border-color 0.12s;
}
.vstudio-models-summary:hover {
    background: #f7f8fb;
    border-color: #d6d6e2;
}
.vstudio-models-summary::-webkit-details-marker { display: none; }
.vstudio-models-summary::before {
    content: '▶';
    display: inline-block;
    font-size: 9px;
    color: var(--text-muted, #9a9aa6);
    transition: transform 0.12s;
}
.vstudio-models-details[open] > .vstudio-models-summary::before {
    transform: rotate(90deg);
}
.vstudio-models-summary-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #1a1a2e;
}
.vstudio-models-summary-selected {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted, #777);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
}
.vstudio-models-summary-selected.is-empty {
    color: #c14b3a;
    font-style: italic;
}
.vstudio-models-details[open] > .vstudio-model-list {
    margin-top: 8px;
}

.vstudio-model-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.vstudio-model-group-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted, #aaa);
    margin-top: 8px;
    margin-bottom: 4px;
    letter-spacing: 0.08em;
}
.vstudio-model-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 10px;
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.12s;
    background: #fff;
}
.vstudio-model-row:hover { border-color: #c7c9d6; background: #fafafd; }
.vstudio-model-row.active {
    border-color: #5B53E8;
    background: #f0f0ff;
}

/* Model group = row + collapsible options panel */
.vstudio-model-group {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.vstudio-model-group .vstudio-model-row {
    border-radius: 8px;
}
.vstudio-model-group.active .vstudio-model-row {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-color: transparent;
}

.vstudio-model-options {
    border: 1px solid #5B53E8;
    border-top: none;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    background: #fafaff;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.vstudio-opt-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.vstudio-opt-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}
.vstudio-opt-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #555);
    text-transform: none;
}
.vstudio-opt-hint {
    font-size: 10px;
    color: var(--text-muted, #aaa);
    line-height: 1.3;
    text-align: right;
    flex: 1;
    min-width: 0;
}
.vstudio-opt-segmented {
    min-height: 32px;
}
.vstudio-opt-segmented .vstudio-seg-btn {
    min-height: 26px;
    padding: 4px 8px;
    font-size: 11px;
}
.vstudio-opt-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 999px;
    background: #fff;
    cursor: pointer;
    font-size: 11px;
    color: var(--text-muted, #888);
    width: fit-content;
    transition: all 0.12s;
}
.vstudio-opt-toggle.on {
    border-color: #5B53E8;
    background: #5B53E8;
    color: #fff;
}
.vstudio-opt-toggle input[type="checkbox"] {
    accent-color: #fff;
    margin: 0;
    width: 12px;
    height: 12px;
}
.vstudio-opt-toggle-state {
    font-weight: 600;
}
.vstudio-opt-select,
.vstudio-opt-number {
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 11px;
    font-family: inherit;
    background: #fff;
    width: 100%;
    outline: none;
}
.vstudio-opt-select:focus,
.vstudio-opt-number:focus {
    border-color: #5B53E8;
}
.vstudio-model-row input[type="checkbox"] {
    margin-top: 2px;
    accent-color: #5B53E8;
}
.vstudio-model-meta { flex: 1; min-width: 0; }
.vstudio-model-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.vstudio-model-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #1a1a2e);
}
.vstudio-model-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1.4;
}
.vstudio-model-badge.alpha {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}
.vstudio-model-hint {
    font-size: 11px;
    color: var(--text-muted, #888);
    margin-top: 1px;
}

/* Floating footer — sticks to the bottom of the controls column
 * regardless of scroll position. Without this it sat at the bottom of
 * a tall scrolled list and required scrolling all the way down to hit
 * Generate. The opaque background + shadow + top divider make it read
 * as a separate UI layer, not just "the last thing in the column".
 *
 * `position: sticky` keeps the footer anchored at the column's bottom
 * edge (relative to the scroll container, .vstudio-controls) — so it
 * floats above any tall content above it. Negative margin pulls past
 * the column's padding so the footer extends edge-to-edge for a
 * cleaner toolbar look. */
.vstudio-footer {
    position: sticky;
    bottom: 0;
    margin-top: auto;       /* still pushes footer to bottom in a short column */
    margin-left: -16px;
    margin-right: -16px;
    margin-bottom: -16px;   /* compensate for parent's padding */
    padding: 14px 16px 16px;
    border-top: 1px solid var(--border-subtle, #e6e6ec);
    background: #fff;
    box-shadow: 0 -4px 14px rgba(15, 23, 42, 0.06);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 5;
}
.vstudio-cost-line {
    font-size: 13px;
    color: var(--text-secondary, #555);
    text-align: center;
}
/* Not enough credits — the 402 shown inline in this section. The image Studio already had this
   as .studio-cost-line.is-short; the video studio uses its own class prefix, so without this the
   SAME message rendered in ordinary grey body text here and read as a hint rather than a blocker. */
.vstudio-cost-line.is-short {
    color: #c0392b;
    font-weight: 600;
}
.vstudio-generate-btn {
    width: 100%;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
}
.vstudio-generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.vstudio-section { display: contents; }

/* ---- Center: Grid ---- */
.vstudio-grid {
    overflow-y: auto;
    overflow-x: auto;
    padding: 20px;
    display: flex;
    gap: 16px;
    align-items: stretch;
    background: var(--bg-secondary, #f7f7fa);
}
.vstudio-grid-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted, #888);
    padding: 60px 40px;
}
.vstudio-grid-empty .vstudio-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}
.vstudio-grid-empty h3 {
    font-size: 18px;
    margin: 0 0 6px;
    color: var(--text-primary, #1a1a2e);
}

.vstudio-track {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--border-subtle, #e6e6ec);
    min-width: 280px;
    width: 320px;
    flex-shrink: 0;
    overflow: hidden;
}
.vstudio-track-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    /* Right padding reserves room for the absolutely-positioned remove
     * (×) corner button (.vstudio-winner-remove-corner — 22px square at
     * top:8 right:8). Without this, a long track-name or status string
     * would slide under the X. */
    padding-right: 42px;
    border-bottom: 1px solid var(--border-subtle, #e6e6ec);
    background: #fafafd;
    /* Anchor for the .vstudio-winner-remove-corner X button which is
     * positioned absolute at top:8 / right:8 (same class + design as
     * the winners-tray remove corner — see css/composer.css). */
    position: relative;
}
.vstudio-track-name {
    font-size: 13px;
    font-weight: 600;
    flex: 1;
    color: var(--text-primary, #1a1a2e);
}
.vstudio-track-status {
    font-size: 11px;
    color: var(--text-muted, #888);
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--bg-tertiary, #f0f1f5);
}
.vstudio-track-status.running {
    color: #5B53E8;
    background: #eef0ff;
}
.vstudio-track-status.done {
    color: #22c55e;
    background: #f0fdf4;
}
.vstudio-track-status.error {
    color: #ef4444;
    background: #fef2f2;
}
.vstudio-track-status.aborted {
    color: #646B78;
}

/* Re-roll tooltip — small popover anchored above the ↻ button on a card.
   Rendered into document.body with position:fixed so it escapes the
   column's overflow:hidden. JS sets `left` and `top` from the button's
   bounding rect; the transform anchors the tooltip's bottom-center to
   the button's top-center with a 12px gap for the arrow. */
.vstudio-reroll-tooltip {
    position: fixed;
    transform: translate(-50%, calc(-100% - 12px));
    background: #fff;
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(20, 20, 40, 0.14);
    padding: 8px;
    width: 260px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.vstudio-reroll-tooltip-textarea {
    width: 100%;
    box-sizing: border-box;
    min-height: 58px;
    padding: 6px 8px;
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-primary, #1a1a2e);
    background: #fff;
    resize: vertical;
    font-family: inherit;
}
.vstudio-reroll-tooltip-textarea:focus {
    outline: none;
    border-color: var(--accent, #5B53E8);
    box-shadow: var(--focus-ring);
}
.vstudio-reroll-tooltip-submit {
    padding: 7px 10px;
    background: var(--accent, #5B53E8);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.12s;
}
.vstudio-reroll-tooltip-submit:hover {
    filter: brightness(0.95);
}
.vstudio-reroll-tooltip-arrow {
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 11px;
    height: 11px;
    background: #fff;
    border-right: 1px solid var(--border-subtle, #e6e6ec);
    border-bottom: 1px solid var(--border-subtle, #e6e6ec);
}

.vstudio-track-cancel {
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted, #888);
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.vstudio-track-cancel:hover { background: var(--bg-tertiary, #f0f1f5); color: #ef4444; }

.vstudio-track-body {
    padding: 12px;
    display: grid;
    /* One image per row inside each generation card. Was 1fr 1fr (two
     * per row) which cramped large concept thumbnails — single column
     * lets each result image render at full card width so on-image
     * text is readable at a glance and the user can star/edit/save
     * actions on the overlay sit on a larger hit area. */
    grid-template-columns: 1fr;
    gap: 8px;
    flex: 1;
    align-content: start;
}
.vstudio-track-error {
    grid-column: 1 / -1;
    padding: 16px;
    background: #fef2f2;
    color: #b91c1c;
    border-radius: 8px;
    font-size: 12px;
    text-align: center;
}
.vstudio-track-retry {
    grid-column: 1 / -1;
    padding: 8px;
    border: 1px solid var(--border-subtle, #e6e6ec);
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}
.vstudio-track-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 6px;
    margin-top: 4px;
}
.vstudio-track-action {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border-subtle, #e6e6ec);
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    color: var(--text-secondary, #555);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.vstudio-track-action:hover { border-color: #5B53E8; color: #5B53E8; }

.vstudio-thumb {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    background: var(--bg-tertiary, #f0f1f5);
    cursor: pointer;
    transition: transform 0.12s;
}
.vstudio-thumb:hover { transform: scale(1.02); }
.vstudio-thumb.video {
    aspect-ratio: 16 / 9;
    /* Span full track-body width — video tracks usually have one variant,
       and a full-width video reads way better than a half-width one
       crammed next to empty space. */
    grid-column: 1 / -1;
}
.vstudio-thumb img,
.vstudio-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.vstudio-thumb.skeleton {
    background: linear-gradient(90deg, #f0f1f5 0%, #e8e9ee 50%, #f0f1f5 100%);
    background-size: 200% 100%;
    animation: studioPulse 1.5s ease-in-out infinite;
}
@keyframes studioPulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.vstudio-thumb-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 50%, rgba(0,0,0,0.6) 100%);
    opacity: 0;
    transition: opacity 0.12s;
    display: flex;
    align-items: flex-end;
    padding: 8px;
    gap: 4px;
}
.vstudio-thumb:hover .vstudio-thumb-overlay { opacity: 1; }
.vstudio-thumb-action {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.95);
    color: #1a1a2e;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s;
}
.vstudio-thumb-action:hover {
    background: #5B53E8;
    color: #fff;
}

/* Favorited state — yellow filled star that stays visible (no fade)
   so the user can tell at a glance which tiles are in the Winners
   tray. Overrides the overlay's default opacity:0 → 1 hover behavior
   for THIS button only; the other actions (re-roll, save) still
   fade in on hover. Click again to remove from winners. */
.vstudio-thumb-action.is-favorited {
    background: #facc15;                /* tailwind yellow-400 */
    color: #78350f;                     /* deep amber for star contrast */
    text-shadow: 0 0 1px rgba(0, 0, 0, 0.2);
    box-shadow: 0 0 0 1.5px #ca8a04, 0 2px 6px rgba(180, 130, 0, 0.35);
    opacity: 1;                         /* always visible */
}
.vstudio-thumb-action.is-favorited:hover {
    background: #fde047;                /* yellow-300 — slightly lighter on hover */
    color: #78350f;
}
/* When the tile is favorited, force the overlay to render the
   star (the only button that needs to be visible without hover).
   We can't keep the whole overlay visible — that'd cover the
   image — so isolate the favorited button. */
.vstudio-thumb.is-winner .vstudio-thumb-overlay {
    opacity: 1;                         /* keep overlay visible so the star shows */
    background: linear-gradient(to bottom, transparent 60%, rgba(0,0,0,0.45) 100%);
}
.vstudio-thumb.is-winner .vstudio-thumb-action:not(.is-favorited) {
    /* But fade the OTHER action buttons unless the user hovers, so
       the tile doesn't feel cluttered just because it's favorited. */
    opacity: 0;
    transition: opacity 0.12s;
}
.vstudio-thumb.is-winner:hover .vstudio-thumb-action:not(.is-favorited) {
    opacity: 1;
}

/* =============================================================================
 * Studio image-edit dialog — opened from the ✎ button on each thumb.
 * Side-by-side: image preview (left) + edit prompt form (right).
 * Sits above everything else in the studio view.
 * ========================================================================== */
.vstudio-edit-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    animation: vstudio-edit-fade-in 0.15s ease-out;
}
@keyframes vstudio-edit-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.vstudio-edit-modal {
    background: #fff;
    border-radius: 16px;
    max-width: 920px;
    width: 100%;
    max-height: calc(100vh - 64px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}
.vstudio-edit-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}
.vstudio-edit-title {
    font-size: 16px;
    font-weight: 700;
    color: #111827;
}
.vstudio-edit-sub {
    flex: 1;
    font-size: 12px;
    color: #6b7280;
}
.vstudio-edit-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}
.vstudio-edit-preview {
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 16px;
    overflow: hidden;
    min-height: 320px;
    gap: 10px;
}
.vstudio-edit-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    align-self: center;
}

/* ============================================================================
 * Studio image-edit dialog — inline mask painter (GPT Image 2 Edit only).
 * Mirrors the canvas editor's openMaskPainter UX but lives inside the popup.
 * Layout: toolbar row → canvas stage → hint line, all stacked in the left
 * column of the dialog body.
 * ========================================================================= */
.vstudio-edit-painter-loading {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    font-size: 13px;
    padding: 40px;
    text-align: center;
}
.vstudio-edit-painter-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    padding: 6px 8px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}
.vstudio-edit-painter-tool {
    background: #fff;
    border: 1px solid #d1d5db;
    color: #374151;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.vstudio-edit-painter-tool:hover {
    background: #eef2ff;
    border-color: #c7d2fe;
    color: #1e40af;
}
.vstudio-edit-painter-tool.is-active {
    background: #5B53E8;
    border-color: #5B53E8;
    color: #fff;
}
.vstudio-edit-painter-size {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 6px;
    font-size: 12px;
    color: #4b5563;
}
.vstudio-edit-painter-size input[type="range"] {
    width: 90px;
    accent-color: #5B53E8;
}
.vstudio-edit-painter-size-label {
    min-width: 36px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: #111827;
    font-weight: 600;
}
.vstudio-edit-painter-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e5e7eb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    /* Checkerboard background so the user can see where the painter
       stage ends even on solid white source images. */
    background-image:
        linear-gradient(45deg, rgba(0,0,0,0.04) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(0,0,0,0.04) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(0,0,0,0.04) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(0,0,0,0.04) 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.vstudio-edit-painter-canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: crosshair;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    /* Disable native touch gestures so painting on touch devices
       doesn't scroll the dialog instead. */
    touch-action: none;
}
.vstudio-edit-painter-hint {
    font-size: 12px;
    color: #6b7280;
    text-align: center;
    line-height: 1.4;
}
.vstudio-edit-form {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
}
.vstudio-edit-label {
    font-size: 13px;
    font-weight: 600;
    color: #111827;
}
.vstudio-edit-textarea {
    width: 100%;
    min-height: 110px;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.5;
    color: #111827;
    background: #fff;
    resize: vertical;
    box-sizing: border-box;
}
.vstudio-edit-textarea:focus {
    outline: none;
    border-color: #5B53E8;
    box-shadow: var(--focus-ring);
}
.vstudio-edit-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.vstudio-edit-chip {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    color: #374151;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 11.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}
.vstudio-edit-chip:hover {
    background: #eef2ff;
    border-color: #c7d2fe;
    color: #1e40af;
}
.vstudio-edit-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12.5px;
}
.vstudio-edit-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: auto;
    padding-top: 4px;
}
.vstudio-edit-btn-secondary,
.vstudio-edit-btn-primary {
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}
.vstudio-edit-btn-secondary {
    background: #fff;
    border-color: #d1d5db;
    color: #374151;
}
.vstudio-edit-btn-secondary:hover:not(:disabled) {
    background: #f9fafb;
}
.vstudio-edit-btn-primary {
    background: #5B53E8;
    color: #fff;
}
.vstudio-edit-btn-primary:hover:not(:disabled) {
    background: #4f46e5;
}
.vstudio-edit-btn-primary:disabled,
.vstudio-edit-btn-secondary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
@media (max-width: 720px) {
    .vstudio-edit-body {
        grid-template-columns: 1fr;
    }
    .vstudio-edit-preview {
        max-height: 30vh;
    }
}

/* "Winner" badge — pins to the top-left corner of any favorited
   thumb. Yellow pill with the star + text. Lives outside the
   overlay so it stays visible regardless of hover state. The
   user immediately sees which tiles are already in the tray. */
.vstudio-thumb-winner-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: #facc15;
    color: #78350f;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 3px 8px;
    border-radius: 10px;
    box-shadow: 0 0 0 1.5px #ca8a04, 0 1px 3px rgba(180, 130, 0, 0.4);
    pointer-events: none;               /* never blocks tile clicks */
    z-index: 2;                          /* above the overlay gradient */
    line-height: 1;
    user-select: none;
}

/* ---- Right: Tray ---- */
.vstudio-tray {
    background: #fff;
    border-left: 1px solid var(--border-subtle, #e6e6ec);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.vstudio-tray-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-subtle, #e6e6ec);
    /* Flex row so the title-text block and Download-all button sit
       side-by-side. The text block grows; the button hugs the right
       edge. Wraps to two lines on very narrow trays. */
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.vstudio-tray-header-text {
    flex: 1;
    min-width: 0;          /* allow ellipsis on the h3 if needed */
}
.vstudio-tray-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #1a1a2e);
}
.vstudio-tray-sub {
    font-size: 11px;
    color: var(--text-muted, #888);
    margin-top: 2px;
    display: block;
}
/* Download-all button in the header. Compact, secondary visual
   weight (icon + label, transparent background until hover). Sits
   on the right of the title block via flex. Disabled state mutes
   to ~40% opacity and disables the hover lift. */
.vstudio-tray-download-all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary, #1a1a2e);
    background: transparent;
    border: 1px solid var(--border, #d6d6dc);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    white-space: nowrap;
}
.vstudio-tray-download-all:hover:not(:disabled) {
    background: var(--accent-subtle, rgba(99, 102, 241, 0.08));
    border-color: var(--accent, #5B53E8);
    color: var(--accent, #5B53E8);
}
.vstudio-tray-download-all:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.vstudio-tray-download-all svg {
    flex-shrink: 0;
}
/* Hide the label text on very narrow trays so the icon-only button
   stays usable. Threshold matches the resize-handle floor (320px). */
@media (max-width: 360px) {
    .vstudio-tray-download-all span { display: none; }
    .vstudio-tray-download-all { padding: 6px 8px; }
}
.vstudio-tray-list {
    flex: 1;
    min-height: 0;             /* allow flex child to shrink below its content height so overflow-y triggers */
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.vstudio-tray-empty {
    color: var(--text-muted, #aaa);
    font-size: 12px;
    text-align: center;
    padding: 24px 16px;
    line-height: 1.5;
}
.vstudio-winner {
    display: flex;
    flex-direction: column;
    background: #fafafd;
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 10px;
    overflow: hidden;
    /* flex-shrink: 0 so cards keep their NATURAL height (full image + meta +
       all action buttons visible) when the tray list has more children than
       fit on screen. Without this, cards proportionally squeeze and the
       bottom action buttons get clipped/hidden. The .vstudio-tray-list
       parent has overflow-y: auto so the list itself scrolls instead. */
    flex-shrink: 0;
}
.vstudio-winner img,
.vstudio-winner video {
    width: 100%;
    height: auto;          /* show the full generated image — no crop */
    display: block;
    /* aspect-ratio + object-fit:cover removed: every winner used to be
       force-cropped to a 1:1 thumbnail, hiding the top/bottom of any
       portrait/landscape result. Now the card flows to the image's
       natural aspect ratio so the user sees exactly what was produced. */
}
.vstudio-winner-meta {
    padding: 8px 10px;
}
.vstudio-winner-model {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary, #1a1a2e);
}
.vstudio-winner-prompt {
    font-size: 11px;
    color: var(--text-muted, #888);
    margin-top: 2px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.vstudio-winner-actions {
    display: flex;
    flex-direction: column;        /* stack vertically — 5+ buttons no longer fit horizontally */
    gap: 4px;
    padding: 0 10px 10px;
}
.vstudio-winner-actions .btn {
    width: 100%;
    font-size: 11px;
    padding: 6px 10px;
    text-align: center;
    justify-content: center;
}
/* Reference image LOGO marker — when one ref is flagged as the brand
   logo, it gets a corner badge + a slight outline so it stands out in
   the references row. */
.vstudio-ref-tile.is-logo .vstudio-ref-thumb {
    outline: 2px solid #5B53E8;
    outline-offset: -2px;
}
.vstudio-ref-logo-badge {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: #5B53E8;
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.06em;
    padding: 2px 5px;
    border-radius: 3px;
    pointer-events: none;
}
.vstudio-ref-logo-toggle {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.92);
    color: #5B53E8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s;
    opacity: 0.6;
}
.vstudio-ref-tile:hover .vstudio-ref-logo-toggle { opacity: 1; }
.vstudio-ref-logo-toggle.active {
    background: #5B53E8;
    color: #fff;
    border-color: #5B53E8;
    opacity: 1;
}

/* Per-reference ROLE — colour-coded outline on the image + the under-image
   type label (which is itself the change-type <select>). */
.vstudio-ref-tile.is-role-product .vstudio-ref-thumb    { outline: 2px solid #10b981; outline-offset: -2px; }
.vstudio-ref-tile.is-role-competitor .vstudio-ref-thumb { outline: 2px solid #f59e0b; outline-offset: -2px; }
/* The role select sits UNDER the image: always visible, full width, doubles as
   the type label + the control to change it. Tinted by role for at-a-glance read. */
.vstudio-ref-role-select {
    width: 100%;
    font-size: 10.5px; font-weight: 700;
    padding: 4px 6px; border-radius: 6px;
    border: 1px solid var(--border-subtle, #e6e6ec);
    background: #fff; color: #334155;
    cursor: pointer;
    text-align: center; text-align-last: center;
}
.vstudio-ref-role-select.role-logo       { border-color: #5B53E8; color: #4338ca; background: #eef2ff; }
.vstudio-ref-role-select.role-product    { border-color: #10b981; color: #047857; background: #ecfdf5; }
.vstudio-ref-role-select.role-competitor { border-color: #f59e0b; color: #b45309; background: #fffbeb; }
.vstudio-ref-role-select.role-reference  { border-color: var(--border-subtle, #e6e6ec); color: #475569; background: #f8fafc; }
.vstudio-ref-logo-toggle:hover {
    background: #5B53E8;
    color: #fff;
    border-color: #5B53E8;
    opacity: 1;
}

/* "Optimized prompt active" indicator below the Optimize button */
.vstudio-optimize-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    margin-top: 4px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 6px;
    font-size: 11px;
    color: #4f46e5;
}
.vstudio-optimize-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #5B53E8;
    box-shadow: 0 0 6px rgba(99, 102, 241, 0.6);
    flex-shrink: 0;
}
.vstudio-optimize-status-text { flex: 1; }
.vstudio-optimize-clear,
.vstudio-optimize-peek {
    color: #5B53E8;
    text-decoration: underline;
    cursor: pointer;
}
.vstudio-optimize-clear:hover,
.vstudio-optimize-peek:hover { color: #4338ca; }

/* Image-size selector inside model options (GPT Image 2) */
.vstudio-opt-imagesize { display: flex; flex-direction: column; gap: 6px; }
.vstudio-opt-imagesize-custom { display: flex; align-items: center; gap: 6px; }
.vstudio-opt-imagesize-custom .vstudio-opt-number { width: 78px; }
.vstudio-opt-imagesize-x { color: var(--text-muted, #888); font-weight: 600; }
/* Custom W × H inputs revealed when "Custom dimensions…" is selected. */
.vstudio-opt-custom-dims {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 0 2px;
}
.vstudio-opt-num-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted, #888);
}
.vstudio-opt-num-x {
    color: var(--text-muted, #aaa);
    font-weight: 600;
}
.vstudio-opt-num-suffix {
    font-size: 11px;
    color: var(--text-muted, #888);
    margin-left: 2px;
}
.vstudio-opt-num-input {
    width: 70px;
    padding: 4px 6px;
    border: 1px solid var(--border, #e6e6ec);
    border-radius: 5px;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    background: #fff;
    color: var(--text-primary, #1a1a2e);
}
.vstudio-opt-num-input:focus {
    outline: none;
    border-color: #5B53E8;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

/* Text overlay mode toggle — sits below the style chips */
.vstudio-overlay-toggle-wrap {
    margin-top: 6px;
    padding: 8px 10px;
    background: #f0f1ff;
    border: 1px solid #d8daf0;
    border-radius: 8px;
}
.vstudio-overlay-toggle {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    font-size: 11px;
    line-height: 1.4;
    color: #2a2d40;
}
.vstudio-overlay-toggle input[type="checkbox"] {
    margin-top: 2px;
    accent-color: #5B53E8;
    cursor: pointer;
}
.vstudio-overlay-toggle-text strong { color: #4f46e5; }
.vstudio-overlay-toggle-hint {
    color: #5b5f78;
    font-weight: 400;
}

/* Extract-and-erase progress overlay — full-screen with backdrop + centered card */
.vstudio-extract-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 21, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: vstudio-extract-fade 0.18s ease-out;
}
@keyframes vstudio-extract-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.vstudio-extract-card {
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.32);
    padding: 32px 36px;
    min-width: min(380px, calc(100vw - 32px));   /* a hard 380 overflowed a 375px phone */
    max-width: 480px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
}
.vstudio-extract-spinner {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid #e6e6ec;
    border-top-color: #5B53E8;
    border-right-color: #5B53E8;
    animation: vstudio-extract-spin 0.8s linear infinite;
}
@keyframes vstudio-extract-spin {
    to { transform: rotate(360deg); }
}
.vstudio-extract-title {
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
}
.vstudio-extract-status {
    font-size: 13px;
    color: #5B53E8;
    font-weight: 500;
    min-height: 1.4em;
    transition: opacity 0.15s;
}
.vstudio-extract-sub {
    font-size: 11px;
    color: #646B78;
    line-height: 1.5;
    max-width: 320px;
}

/* The remove (×) button stays small and sits on its own row, right-aligned */
.vstudio-winner-remove {
    align-self: flex-end !important;
    width: 28px !important;
    padding: 4px !important;
    color: var(--text-muted, #888);
}
.vstudio-tray-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-subtle, #e6e6ec);
    background: #fafafd;
}
/* Winners-rail footer actions (2026-07-14): the fork's class rename
   (studio- → vstudio-) orphaned the composer.css/ads-wizard.css rules, so
   "Edit selected in Canvas" + "Create Meta Ads" rendered content-width and
   ragged. Same treatment as the image studio: full-width, stacked, aligned. */
.vstudio-tray-composer-btn {
    width: 100%;
    margin-bottom: 6px;
}
.vstudio-tray-composer-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.vstudio-tray-ads-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.vstudio-tray-composer-hint {
    font-size: 10px;
    color: var(--text-muted, #aaa);
    text-align: center;
    margin-bottom: 8px;
    min-height: 14px;
    line-height: 1.4;
}
.vstudio-tray-spent {
    font-size: 12px;
    color: var(--text-secondary, #555);
    text-align: center;
}

/* ---- Preview overlay ---- */
.vstudio-preview-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    cursor: zoom-out;
}
.vstudio-preview-img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}
/* Full-size video preview — same modal behavior as image, native controls */
.vstudio-preview-video-wrap {
    max-width: 92vw;
    max-height: 92vh;
    cursor: default;            /* override the overlay's zoom-out cursor */
    display: flex;
    align-items: center;
    justify-content: center;
}
.vstudio-preview-video {
    max-width: 92vw;
    max-height: 92vh;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    background: #000;
}

/* ===========================================================================
   Rich image lightbox — used for generated image results in AI Studio.
   Adds prev/next navigation, a thumbnail strip, and in-zoom action buttons
   (favorite, download, reroll). Click-backdrop and Esc/arrow keys work too.
   =========================================================================== */
.vstudio-preview-overlay--lightbox {
    cursor: default;                        /* overrides .vstudio-preview-overlay zoom-out */
    flex-direction: column;
    padding: 16px 0 0;
    background: rgba(0, 0, 0, 0.92);
}
.vstudio-lightbox-actions {
    position: fixed;
    top: 14px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 2;
}
.vstudio-lightbox-meta {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.78);
    background: rgba(255, 255, 255, 0.08);
    padding: 6px 10px;
    border-radius: 999px;
    margin-right: 4px;
    max-width: 280px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.vstudio-lightbox-action {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s;
    font-family: inherit;
}
/* Admin-only action (set concept preview) — subtle green tint to set it apart. */
.vstudio-lightbox-action-admin { border-color: rgba(34, 197, 94, 0.5); color: #4ade80; }
.vstudio-lightbox-action-admin:hover { background: rgba(34, 197, 94, 0.2); }
.vstudio-lightbox-action:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}
.vstudio-lightbox-action.is-active,
.vstudio-lightbox-action.is-active-add {
    /* Brief pulse when an image is ADDED to winners — amber circle
       (matches the persistent amber color of the favorited star). */
    background: #f59e0b;
    border-color: #f59e0b;
    color: #fff;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.25);
}
.vstudio-lightbox-action.is-active-remove {
    /* Brief pulse when an image is REMOVED from winners. Deliberately
       NOT amber — using the favorited color for the unfavorite gesture
       read as "still selected" and made the toggle feel broken. Muted
       neutral ring with dimmed star = clear "no longer favorited"
       signal that can't be confused for the favorited state. */
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.30);
    color: rgba(255, 255, 255, 0.45);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.10);
}
.vstudio-lightbox-viewport {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    position: relative;
    padding: 0 64px;
    box-sizing: border-box;
    min-height: 0;
}
.vstudio-lightbox-main {
    max-width: 100%;
    max-height: calc(100vh - 250px);        /* leaves room for strip + actions + hint */
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}
/* Winner ✓ — green badge in the image's top-right when the current creative is
   a winner (mirrors the ★ action button). Toggled via .is-visible in render(). */
.vstudio-lightbox-winner-check {
    position: absolute;
    top: 14px;
    right: 72px;
    width: 34px;
    height: 34px;
    display: none;
    align-items: center;
    justify-content: center;
    background: #16a34a;
    color: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(22, 163, 74, 0.5);
    z-index: 3;
}
.vstudio-lightbox-winner-check.is-visible { display: flex; }
/* Space-to-toggle hint under the image. */
.vstudio-lightbox-hint {
    flex: 0 0 auto;
    text-align: center;
    padding: 10px 0 2px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.82);
}
.vstudio-lightbox-kbd {
    display: inline-block;
    padding: 2px 8px;
    margin-right: 3px;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 6px;
}
.vstudio-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 80px;
    border-radius: 8px;
    border: 0;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 38px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.12s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}
.vstudio-lightbox-nav:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.18);
}
.vstudio-lightbox-nav:disabled {
    opacity: 0.25;
    cursor: default;
}
.vstudio-lightbox-nav.prev { left: 12px; }
.vstudio-lightbox-nav.next { right: 12px; }
.vstudio-lightbox-strip {
    flex: 0 0 auto;
    display: flex;
    gap: 6px;
    padding: 12px 16px 16px;
    overflow-x: auto;
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
.vstudio-lightbox-strip::-webkit-scrollbar { height: 6px; }
.vstudio-lightbox-strip::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}
.vstudio-lightbox-thumb {
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    border-radius: 6px;
    border: 2px solid transparent;
    background: rgba(255, 255, 255, 0.04);
    padding: 0;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.12s, transform 0.12s;
}
.vstudio-lightbox-thumb:hover { transform: scale(1.04); }
.vstudio-lightbox-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.vstudio-lightbox-thumb.is-active {
    border-color: #5B53E8;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}
/* Winner marker on lightbox thumbnails — yellow star badge in the
   top-right corner of the thumb when the image is in state.winners.
   The thumb itself also picks up a subtle yellow border so the
   "this is a winner" signal is visible at a glance even when the
   thumb isn't the currently-active one (which has its own indigo
   border). */
.vstudio-lightbox-thumb.is-winner {
    position: relative;
    border-color: #f59e0b;        /* amber-500 */
    box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.35);
}
.vstudio-lightbox-thumb.is-winner.is-active {
    /* When a winner is ALSO the active thumb, indigo wins on the
       border (active state is more transient/important) but we keep
       the amber glow so the user still sees the winner cue. */
    border-color: #5B53E8;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.4), 0 0 0 4px rgba(245, 158, 11, 0.35);
}
.vstudio-lightbox-thumb-winner {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #f59e0b;
    color: #fff;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
    pointer-events: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
/* Action-bar ★ button when the CURRENT image is favorited.
   Same amber accent the grid star uses, so the visual language
   is consistent between the grid tile and the lightbox. */
.vstudio-lightbox-action.is-favorited {
    color: #f59e0b;
}
@media (max-width: 640px) {
    .vstudio-lightbox-viewport { padding: 0 12px; }
    .vstudio-lightbox-nav { width: 38px; height: 60px; font-size: 28px; }
    .vstudio-lightbox-meta { display: none; }
    .vstudio-lightbox-thumb { width: 48px; height: 48px; }
}

/* ---- Sidebar Studio nav button ----
   No special highlight: the Studio item uses the SAME clean active pill as
   every other nav item (.nav-item.active → --accent-subtle). The old bold
   purple gradient made Studio look "much more colored" than its peers. */

/* ---- Responsive: collapse columns on narrow screens ---- */
@media (max-width: 1100px) {
    .vstudio-main {
        /* Left bar holds its 365px minimum in the tablet range too (drag-resize is
           a >1100px affordance); right tray stays at 280px, center flexes. */
        grid-template-columns: 365px 1fr 280px;
    }
    /* The two drag handles are grid ITEMS: with 3 tracks they took the 1fr and 280px cells and
       pushed the results grid + tray into the wrong columns / a second row (QA 2026-11-08, 1000px). */
    .vstudio-main > .vstudio-resize-handle { display: none; }
}
@media (max-width: 900px) {
    .vstudio-main {
        grid-template-columns: 1fr;
        /* Stack the three panels and let the page scroll. The old bounded `auto 1fr auto`
           split (plus the two resize handles taking rows) left the whole form ~270px tall on
           a phone (QA 2026-11-08). */
        grid-template-rows: none;
        grid-auto-rows: max-content;
        overflow-y: auto;
    }
    .vstudio-main > .vstudio-controls { max-height: 82vh; }
    .vstudio-main > .vstudio-grid { min-height: 50vh; }
    .vstudio-controls { border-right: none; border-bottom: 1px solid var(--border-subtle, #e6e6ec); }
    .vstudio-tray { border-left: none; border-top: 1px solid var(--border-subtle, #e6e6ec); }
}

/* ===========================================================================
 * Variant-type picker modal — fired from winner card → "Variations…" button.
 * Catalog of 12 creative types + 5 legacy cosmetic axes, multi-select with
 * one Generate button. See js/studio/vstudio-tray.js#_openVariantTypePicker.
 * ========================================================================= */
.variant-picker-modal {
    width: min(700px, 92vw);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
}
.variant-picker-body {
    overflow-y: auto;
    padding: 18px;
    flex: 1;
}
.variant-picker-preview {
    display: flex;
    gap: 14px;
    padding: 12px;
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 8px;
    background: var(--bg-subtle, #f8fafc);
    margin-bottom: 18px;
}
.variant-picker-thumb {
    width: 88px;
    height: 88px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}
.variant-picker-preview-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.variant-picker-preview-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text, #1f2937);
}
.variant-picker-preview-sub {
    font-size: 12px;
    color: var(--text-muted, #6b7280);
    line-height: 1.4;
}

.variant-picker-section {
    margin-bottom: 18px;
}
.variant-picker-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.variant-picker-section-title {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted, #6b7280);
}
.variant-picker-select-all {
    background: transparent;
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    color: var(--text-muted, #6b7280);
    cursor: pointer;
    font-family: inherit;
}
.variant-picker-select-all:hover {
    color: var(--accent, #5B53E8);
    border-color: var(--accent, #5B53E8);
}
.variant-picker-section-hint {
    font-size: 11px;
    color: var(--text-muted, #9ca3af);
    font-style: italic;
    margin-bottom: 8px;
    line-height: 1.4;
}

/* Tier-grouped creative types — Tier 1 (top performers) renders first
   and most prominent. Tier 2 (situational) and Tier 3 (niche) follow
   with slightly reduced visual weight so the eye lands on Tier 1 first. */
.variant-picker-tier-group {
    margin-bottom: 14px;
}
.variant-picker-tier-group:last-child {
    margin-bottom: 0;
}
.variant-picker-tier-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.variant-picker-tier-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text, #1f2937);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.variant-picker-tier-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1.2;
}
.variant-picker-tier-badge.tier-1 {
    background: var(--accent, #5B53E8);
    color: #ffffff;
}
.variant-picker-tier-badge.tier-2 {
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent, #5B53E8);
}
.variant-picker-tier-badge.tier-3 {
    background: var(--bg-muted, #f3f4f6);
    color: var(--text-muted, #6b7280);
}
.variant-picker-tier-hint {
    font-size: 11px;
    color: var(--text-muted, #9ca3af);
    line-height: 1.4;
    margin-bottom: 6px;
}

.variant-picker-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
@media (max-width: 600px) {
    .variant-picker-list { grid-template-columns: 1fr; }
}
.variant-picker-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 6px;
    background: var(--bg, #ffffff);
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s;
}
.variant-picker-row:hover {
    border-color: var(--border, #d1d5db);
    background: var(--bg-hover, #f9fafb);
}
.variant-picker-row > input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
}
.variant-picker-row:has(input:checked) {
    border-color: var(--accent, #5B53E8);
    background: var(--accent-soft, rgba(99, 102, 241, 0.06));
}
.variant-picker-row-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.variant-picker-row-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text, #1f2937);
    line-height: 1.3;
}
.variant-picker-row-sub {
    font-size: 11px;
    color: var(--text-muted, #6b7280);
    line-height: 1.3;
}

.variant-picker-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: flex-end;
    padding: 14px 18px;
    border-top: 1px solid var(--border-subtle, #e6e6ec);
}
/* Reference-image picker popup — appears after a successful URL scrape.
   Shows up to 50 lazy-loaded thumbs in a responsive grid; user picks
   up to 7 to feed as references. Auto-pre-selects og:image + JSON-LD
   product images as the most-likely heroes. */
.vstudio-refpick-modal {
    max-width: 1100px;
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}
.vstudio-refpick-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle, #e6e6ec);
}
.vstudio-refpick-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    flex: 1;
    color: var(--text-primary, #1a1a2e);
}
.vstudio-refpick-counter {
    font-size: 12px;
    color: var(--text-muted, #6b7280);
    font-variant-numeric: tabular-nums;
}
/* Deselect-all secondary button in the header. Small, text-only chip
   that sits between the counter and the modal close button. Dimmed
   when there's nothing to deselect. */
.vstudio-refpick-deselect-all {
    margin: 0 4px;
    padding: 5px 10px;
    border: 1px solid var(--border-subtle, #e6e6ec);
    background: #fff;
    color: var(--text-secondary, #4b5563);
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    font-family: inherit;
}
.vstudio-refpick-deselect-all:hover:not(.is-disabled) {
    background: #fef2f2;
    color: #ef4444;
    border-color: #ef4444;
}
.vstudio-refpick-deselect-all.is-disabled,
.vstudio-refpick-deselect-all:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}
.vstudio-refpick-hint {
    margin: 0;
    padding: 10px 18px;
    font-size: 12px;
    color: var(--text-muted, #6b7280);
    background: #fafafd;
    border-bottom: 1px solid var(--border-subtle, #e6e6ec);
    line-height: 1.5;
}
/* Grid sizing + spacing — fixed 5-column layout per user spec.
   Library page (css/library.css .library-grid) uses auto-fill from a
   320px floor; here we want exactly 5 per row at all viewport widths
   so the user always sees a predictable 5×N grid of candidates.
   Padding + gap match Library for visual consistency. */
.vstudio-refpick-grid {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 20px 28px 40px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 18px;
    align-content: start;
}
/* Narrow viewports — drop to 3 / 2 columns when 5 would crush each
   tile below readable size. Below 600px wide the popup itself is
   usually full-screen, so a fixed 5 looks claustrophobic. */
@media (max-width: 900px) {
    .vstudio-refpick-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
    .vstudio-refpick-grid { grid-template-columns: repeat(2, 1fr); }
}
/* Tile dimensions + chrome mirror .library-tile exactly: padding-bottom
   100% reserves a square cell the grid honors, image fills via absolute
   positioning. Same border / radius / hover lift / shadow as Library.
   The native <button> element is reset to look like the library div. */
.vstudio-refpick-tile {
    position: relative;
    width: 100%;
    padding: 0 0 100% 0;
    background: var(--bg-tertiary, #f0f1f5);
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
    outline: none;
    font: inherit;
    color: inherit;
    text-align: left;
}
.vstudio-refpick-tile img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #fff;
}
.vstudio-refpick-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
    border-color: #5B53E8;
}
.vstudio-refpick-tile.is-selected {
    border-color: #5B53E8;
    box-shadow: var(--focus-ring);
}
.vstudio-refpick-tile.is-broken {
    opacity: 0.4;
    pointer-events: none;
}
.vstudio-refpick-tile.is-broken::after {
    content: '⚠ load failed';
    position: absolute;
    inset: auto 0 0 0;
    padding: 6px;
    text-align: center;
    background: rgba(239, 68, 68, 0.9);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
}
.vstudio-refpick-tile.is-capped {
    animation: vstudio-refpick-shake 0.4s ease;
}
@keyframes vstudio-refpick-shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-4px); }
    75%      { transform: translateX(4px); }
}
.vstudio-refpick-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: var(--accent, #5B53E8);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    opacity: 0;
    transform: scale(0.7);
    transition: opacity 0.12s, transform 0.12s;
    pointer-events: none;
}
.vstudio-refpick-tile.is-selected .vstudio-refpick-badge {
    opacity: 1;
    transform: scale(1);
}
.vstudio-refpick-label {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(20, 20, 40, 0.78);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    pointer-events: none;
}
.vstudio-refpick-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid var(--border-subtle, #e6e6ec);
    background: #fafafd;
}

.variant-picker-count {
    margin-right: auto;
    margin-left: 0;
    font-size: 12px;
    color: var(--text-muted, #6b7280);
}

/* ── Recent runs (V2-port of the image studio's S1) — Source card panel ───── */
.vstudio-recent { margin-top: 10px; border: 1px solid var(--border, #e2e4ea); border-radius: 10px; background: var(--bg-secondary, #f7f8fa); overflow: hidden; }
.vstudio-recent-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 12px; border: none; background: none; font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-secondary, #6b7280); cursor: pointer; }
.vstudio-recent-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--border, #e2e4ea); font-size: 10.5px; font-weight: 650; color: var(--text-secondary, #6b7280); }
.vstudio-recent-chev { margin-left: auto; display: inline-flex; transition: transform 0.15s ease; }
.vstudio-recent.is-open .vstudio-recent-chev { transform: rotate(180deg); }
.vstudio-recent-list { display: flex; flex-direction: column; padding: 0 6px 6px; }
.vstudio-recent-row { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 7px 8px; border: none; border-radius: 8px; background: none; font-family: inherit; text-align: left; cursor: pointer; }
.vstudio-recent-row:hover { background: var(--bg-primary, #fff); }
.vstudio-recent-row-title { font-size: 12px; color: var(--text-primary, #2a3343); line-height: 1.35; }
.vstudio-recent-row-meta { font-size: 10.5px; color: var(--text-muted, #9ca3af); font-variant-numeric: tabular-nums; }

/* ── Concept search (V5-port of the image studio's S4) ────────────────────── */
.vstudio-concept-search { width: 100%; height: 32px; margin: 0 0 8px; border: 1px solid var(--border, #e2e4ea); border-radius: 8px; padding: 0 10px; font-size: 12.5px; font-family: inherit; outline: none; background: var(--bg-primary, #fff); color: var(--text-primary, #2a3343); box-sizing: border-box; }
.vstudio-concept-search:focus { border-color: var(--accent, #5b53e8); box-shadow: 0 0 0 3px rgba(91,83,232,.1); }
.vstudio-concept-row.is-filtered-out { display: none; }
.vstudio-concepts-group.is-filtered-out { display: none; }

/* ── Accordion step checkmarks (V6-port of the image studio's S6) ─────────── */
.vstudio-acc-check { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: rgba(22, 163, 74, 0.12); color: #16a34a; flex: 0 0 auto; margin-left: 6px; }
.vstudio-acc-card.is-done .vstudio-acc-num { background: rgba(22, 163, 74, 0.12); color: #16a34a; }

/* ── Copy-prompt affordances (V7-port of the image studio's S7) ───────────── */
.vstudio-winner-prompt.is-copyable { cursor: pointer; }
.vstudio-winner-prompt.is-copyable:hover { color: var(--accent, #5b53e8); text-decoration: underline dotted; }

/* ── Winner labels + select-all (V9-port of the image studio's S10+S12) ───── */
.vstudio-tray-select-all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary, #1a1a2e);
    background: transparent;
    border: 1px solid var(--border, #d6d6dc);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    white-space: nowrap;
}
.vstudio-tray-select-all:hover {
    background: var(--accent-subtle, rgba(99, 102, 241, 0.08));
    border-color: var(--accent, #5B53E8);
    color: var(--accent, #5B53E8);
}
.vstudio-winner-label { width: 100%; height: 24px; margin: 3px 0 2px; border: 1px dashed transparent; border-radius: 6px; padding: 0 6px; font-size: 11.5px; font-family: inherit; background: transparent; color: var(--text-primary, #2a3343); box-sizing: border-box; }
.vstudio-winner-label::placeholder { color: var(--text-muted, #9ca3af); }
.vstudio-winner-label:hover { border-color: var(--border, #e2e4ea); }
.vstudio-winner-label:focus { outline: none; border-style: solid; border-color: var(--accent, #5b53e8); background: var(--bg-primary, #fff); }
/* "Published → {ad}" link on a picked winner — shown after it's pushed to Meta
 * (stamped on the meta-ads-created event). Opens the ad in Ads Manager. */
.vstudio-winner-adlink { display: inline-block; margin-top: 3px; max-width: 100%; font-size: 10.5px; font-weight: 700; color: #1877F2; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vstudio-winner-adlink:hover { text-decoration: underline; }
/* Live Meta performance chip on a published winner (spend · ROAS / leads / clicks). */
.vstudio-winner-perf { display: inline-block; margin-top: 3px; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 5px; color: #334155; background: #eef1f6; }
.vstudio-winner-perf.is-good { color: #0b7a53; background: #e5f6ee; }
.vstudio-winner-perf.is-bad  { color: #b45309; background: #fef3e2; }

/* ── UGC error-stage retry (V10 — fork-native) ────────────────────────────── */
.vsu-stage-retry { margin: 12px auto 2px; display: inline-flex; }

/* ============================================================================
 * Add-reference failure alert
 * A toast was too quiet for this: the reference just never appeared and the
 * message was gone before the user looked. Closes on the X only, per the
 * app-wide popup rule.
 * ========================================================================== */
.studio-refalert-modal { max-width: 560px; width: 92vw; padding: 0; }
.studio-refalert-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; padding: 18px 20px 12px;
}
.studio-refalert-title { margin: 0; font-size: 17px; font-weight: 700; color: #B42318; }
.studio-refalert-advice {
    margin: 0; padding: 0 20px 14px;
    font-size: 13.5px; line-height: 1.6; color: var(--text, #1F2430);
}
.studio-refalert-list {
    margin: 0 20px; border: 1px solid #EAECF0; border-radius: 10px;
    background: #FCFCFD; overflow: hidden;
}
.studio-refalert-row {
    display: flex; flex-direction: column; gap: 2px;
    padding: 9px 12px; font-size: 12px; line-height: 1.5;
}
.studio-refalert-row + .studio-refalert-row { border-top: 1px solid #EAECF0; }
.studio-refalert-file { font-weight: 600; color: #344054; word-break: break-all; }
.studio-refalert-reason { color: #667085; word-break: break-word; }
.studio-refalert-foot { display: flex; justify-content: flex-end; padding: 16px 20px 18px; }
