/* =========================================================
   UX OPTIMIZATIONS v2 — Impactful, visible improvements
   ========================================================= */

/* ─── SIDEBAR: Scroll middle content, pin logo + footer ─── */

.sidebar-left {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
}
.sidebar-left::-webkit-scrollbar { width: 3px; }
.sidebar-left::-webkit-scrollbar-track { background: transparent; }
.sidebar-left::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.08); border-radius: 3px; }

.sidebar-logo {
    flex-shrink: 0;
    min-height: 68px;
    box-sizing: border-box;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface);
}

.sidebar-footer {
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 2;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.sidebar-meta-compact {
    flex-shrink: 0;
}

/* ─── SIDEBAR: Active indicator + better spacing ─── */

.sidebar-nav-item {
    padding: 0.5rem 0.75rem;
    min-height: 36px;
    border-radius: 8px;
    font-size: 0.8rem;
    gap: 0.65rem;
    position: relative;
    margin-bottom: 1px;
}

.sidebar-nav-item.active {
    background: rgba(124, 92, 252, 0.12);
    color: #fff;
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar-nav-item.active .nav-icon svg {
    color: var(--accent);
}

.sidebar-section {
    padding: 0.3rem 0.55rem;
}

.sidebar-section-title {
    font-size: 0.6rem;
    letter-spacing: 1.2px;
    padding: 0.5rem 0.75rem 0.2rem;
    color: var(--text-subtle);
    font-weight: 700;
}

.sidebar-divider {
    margin: 0.3rem 0.75rem;
    background: var(--border);
    opacity: 0.5;
}

.sidebar-footer {
    padding: 0.4rem 0.55rem 0.5rem;
}
.sidebar-footer-btn {
    padding: 0.5rem 0.65rem;
    min-height: 36px;
    border-radius: 8px;
    font-size: 0.78rem;
}

.sidebar-usage-mini {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.65rem;
    margin: 0.3rem 0.55rem;
}
.sidebar-usage-mini .usage-mini-bar {
    height: 4px;
    border-radius: 2px;
}

.sidebar-meta-compact {
    margin: 0.3rem 0.55rem;
    padding: 0.5rem;
}

/* ─── TOPBAR: More polished ─── */

.app-topbar-inner {
    padding: 0.85rem 1.5rem;
}
.app-topbar-module {
    font-weight: 700;
    letter-spacing: 0.02em;
}
.app-topbar-tokenbtn {
    gap: 0.4rem;
    font-weight: 700;
}


/* ─── FORMS: Bigger inputs, better hierarchy ─── */

.form-input,
.form-select {
    padding: 0.8rem 1rem;
    min-height: 46px;
    font-size: 0.9rem;
    border-radius: 10px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-textarea {
    padding: 0.8rem 1rem;
    min-height: 110px;
    font-size: 0.9rem;
    line-height: 1.6;
}

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.form-section-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.form-section-desc {
    font-size: 0.88rem;
    margin-bottom: 2rem;
    line-height: 1.55;
    color: var(--text-muted);
}

.form-card {
    padding: 2rem;
    border-radius: 16px;
}

.form-grid {
    gap: 1.35rem;
    margin-bottom: 1.5rem;
}

.form-select {
    padding-right: 2.5rem;
    background-position: right 14px center;
    background-size: 14px;
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-subtle);
    font-size: 0.85rem;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-subtle);
    margin-top: 0.35rem;
    line-height: 1.4;
}


/* ─── GENERATE BUTTON: More prominent CTA ─── */

.generate-btn {
    padding: 1rem 1.5rem;
    font-size: 1.05rem;
    font-weight: 700;
    border-radius: 14px;
    margin-top: 1rem;
    min-height: 54px;
    letter-spacing: 0.01em;
    box-shadow: 0 4px 15px rgba(124, 92, 252, 0.2);
}
.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(124, 92, 252, 0.35);
}
.generate-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(124, 92, 252, 0.2);
    transition-duration: 80ms;
}


/* ─── TABS: Clearer active state ─── */

.tab-btn {
    padding: 0.75rem 1.3rem;
    font-size: 0.85rem;
    font-weight: 600;
    min-height: 44px;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tab-btn:hover {
    color: var(--text);
    background: rgba(0,0,0,0.03);
    border-radius: 8px 8px 0 0;
}
.tab-btn.active {
    color: var(--accent);
    border-bottom: 2px solid var(--accent);
    font-weight: 700;
}


/* ─── NIVEL CARDS: Better touch targets ─── */

.nivel-card {
    padding: 1rem 0.8rem;
    border-radius: 12px;
    min-height: 48px;
    transition: all 0.2s;
}
.nivel-card:hover {
    border-color: var(--accent);
    background: rgba(124, 92, 252, 0.04);
}
.nivel-card.selected {
    border-color: var(--accent);
    background: rgba(124, 92, 252, 0.12);
    box-shadow: 0 0 0 3px rgba(124, 92, 252, 0.2);
}
.nivel-icon { font-size: 1.5rem; }
.nivel-card strong { font-size: 0.84rem; }


/* ─── DASHBOARD HOME ─── */

.home-greeting {
    font-size: 1.8rem !important;
    font-weight: 800 !important;
    letter-spacing: -0.02em;
}

.home-stat-card {
    padding: 1.25rem;
    border-radius: 14px;
    transition: all 0.2s;
}
.home-stat-card:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.home-stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}
.home-stat-bar {
    height: 6px;
    border-radius: 3px;
}
.home-stat-bar-fill {
    border-radius: 3px;
}

.home-card {
    padding: 1.4rem;
    border-radius: 16px;
    transition: border-color 0.2s;
}
.home-card:hover {
    border-color: var(--border-strong);
}
.home-card-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
}

.home-quick-action {
    padding: 0.85rem 1.1rem;
    border-radius: 12px;
    min-height: 54px;
    gap: 0.9rem;
    transition: all 0.15s;
}
.home-quick-action:hover {
    background: var(--surface-3);
    border-color: var(--accent);
    transform: none;
    box-shadow: inset 3px 0 0 var(--accent);
}

.home-hero-card {
    border-radius: 16px;
    min-height: 230px;
    padding: 1.75rem;
}
.home-hero-h3 {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.25;
}
.home-hero-cta {
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0.65rem 1.15rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.home-hero-cta:hover {
    box-shadow: 0 4px 16px rgba(124, 92, 252, 0.3);
}

/* Create cards: more visual punch */
.home-create-card {
    padding: 1.15rem 1.3rem;
    border-radius: 14px;
    transition: all 0.2s var(--ease-standard);
}
.home-create-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(124, 92, 252, 0.15);
}
.home-create-card-icon {
    width: 50px;
    height: 50px;
    border-radius: 14px;
}

/* Template cards: stronger presence */
.home-template-card {
    padding: 1.5rem;
    border-radius: 18px;
    box-shadow: var(--elev-2);
}
.home-template-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 40px rgba(124, 92, 252, 0.2);
}
.home-template-card-icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.home-template-card-title {
    font-size: 1.1rem;
    font-weight: 700;
}
.home-template-card-steps {
    padding: 0.6rem 0.85rem;
    border-radius: 10px;
    font-size: 0.72rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
}


/* ─── LIBRARY (Biblioteca) — Optimized layout ─── */

.bib-v2-wrap {
    padding: 1.25rem 1.5rem 2rem;
    max-width: 1400px;
}

.bib-v2-title {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.bib-v2-toolbar {
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.bib-v2-search {
    flex: 1;
    min-width: 220px;
}
.bib-v2-search input {
    min-height: 42px;
    font-size: 0.85rem;
    border-radius: 10px;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
}

.bib-v2-filter {
    min-height: 42px;
    border-radius: 10px;
}
.bib-v2-toggle-fav {
    width: 42px;
    height: 42px;
    border-radius: 10px;
}

/* Chips: compact horizontal strip */
.bib-v2-chips {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.bib-v2-chip {
    min-height: 32px;
    border-radius: 8px;
    padding: 0.3rem 0.7rem;
    font-weight: 600;
    font-size: 0.75rem;
    gap: 0.3rem;
    transition: all 0.15s;
}
.bib-v2-chip i { width: 13px; height: 13px; }
.bib-v2-chip span { font-size: 0.68rem; opacity: 0.7; }
.bib-v2-chip.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.bib-v2-btn-primary {
    padding: 0.6rem 1.1rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow: 0 3px 10px rgba(124, 92, 252, 0.18);
}

/* Section headers: tighter */
.bib-v2-section-header {
    margin-bottom: 0.6rem;
}
.bib-v2-section-header h3 {
    font-size: 0.82rem;
    letter-spacing: 0.04em;
}
.bib-v2-sections {
    gap: 1.75rem;
}

/* Grids: more items per row, less wasted space */
.bib-v2-section-grid { gap: 0.75rem; }
.bib-v2-grid-imagenes { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.bib-v2-grid-ideas { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.bib-v2-grid-copyout { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.bib-v2-grid-escaletas { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.bib-v2-grid-ofertas { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.bib-v2-grid-estrategias { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.bib-v2-grid-hooksbank { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.bib-v2-grid-inspo { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

/* Cards: tighter, more content density */
.bib-v2-card {
    border-radius: 10px;
}
.bib-v2-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 10%, transparent);
}
.bib-v2-card-header {
    padding: 0.6rem 0.75rem 0.4rem;
}
.bib-v2-card-marca {
    font-size: 0.65rem;
    padding: 2px 6px;
}
.bib-v2-card-date {
    font-size: 0.65rem;
}
.bib-v2-card-hook-large {
    padding: 0.65rem 0.75rem;
    font-size: 0.84rem;
}
.bib-v2-card-preview {
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
}
.bib-v2-card-tags {
    padding: 0.2rem 0.75rem;
    gap: 0.2rem;
}
.bib-v2-mini-tag {
    font-size: 0.6rem;
    padding: 1px 5px;
}
.bib-v2-card-actions {
    padding: 0.5rem 0.75rem;
    gap: 0.3rem;
}
.bib-v2-btn-sm,
.bib-v2-btn-primary-sm {
    padding: 0.3rem 0.5rem;
    font-size: 0.72rem;
    border-radius: 6px;
}
.bib-v2-btn-sm i,
.bib-v2-btn-primary-sm i { width: 12px; height: 12px; }

/* Image cards: better image ratio */
.bib-v2-card-img-wrap {
    aspect-ratio: 4/3;
}
.bib-v2-card-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.bib-v2-card-image-body {
    padding: 0.5rem 0.65rem;
}

/* Inspo/análisis cards: visual distinction */
.bib-v2-card-inspo {
    border-left: 3px solid #06b6d4;
}

/* Empty state: less vertical space */
.bib-v2-empty-state {
    padding: 2rem 1rem;
}
.bib-v2-empty-state i {
    width: 40px;
    height: 40px;
}

/* Legacy bib-card overrides */
.bib-card {
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.15s;
}
.bib-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    border-color: var(--accent);
}
.bib-card-header {
    padding: 0.85rem 1rem 0.6rem;
}
.bib-card-title {
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.35;
}
.bib-card-body {
    padding: 0 1rem 0.7rem;
    font-size: 0.82rem;
    line-height: 1.5;
}
.bib-card-actions {
    padding: 0.6rem 1rem;
    border-top: 1px solid var(--border);
    gap: 0.4rem;
}
.bib-card-btn {
    min-height: 34px;
    padding: 0.35rem 0.65rem;
    border-radius: 7px;
    font-size: 0.74rem;
    font-weight: 600;
    transition: all 0.15s;
}
.bib-card-type {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 5px;
    letter-spacing: 0.03em;
}


/* ─── RESULT SECTIONS: Better content readability ─── */

.section-copy-btn {
    min-width: 38px;
    min-height: 38px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    opacity: 0.6;
}
.section-copy-btn:hover {
    opacity: 1;
    background: var(--accent-soft);
    color: var(--accent);
    transform: scale(1.08);
}


/* ─── TIP STRIP: More visible ─── */

.home-tip-strip {
    border-radius: 12px;
    padding: 0.85rem 1.15rem;
    border: 1px solid rgba(124, 92, 252, 0.2);
    background: rgba(124, 92, 252, 0.06);
}
.home-tip-strip-text {
    font-size: 0.84rem;
    line-height: 1.5;
}


/* ─── MOBILE: Real improvements ─── */

@media (max-width: 768px) {
    .sidebar-left {
        width: 56px;
    }
    .main-content-v2 {
        margin-left: 56px;
    }
    .sidebar-nav-item {
        justify-content: center;
        padding: 0.65rem;
        min-height: 44px;
        margin-bottom: 1px;
    }
    .sidebar-nav-item.active {
        box-shadow: inset 3px 0 0 var(--accent);
    }
    .sidebar-nav-item .nav-icon { width: 24px; }
    .sidebar-nav-item .nav-icon svg { width: 20px; height: 20px; }
    .sidebar-section { padding: 0.3rem 0.35rem; }
    .sidebar-meta-compact { margin: 0.3rem 0.35rem; padding: 0.4rem; }
    .sidebar-footer { padding: 0.5rem 0.35rem; }
    .sidebar-footer-btn { justify-content: center; padding: 0.5rem; }

    .form-card {
        padding: 1.25rem;
        border-radius: 14px;
    }
    .form-grid {
        grid-template-columns: 1fr;
        gap: 1.1rem;
    }
    .generate-btn {
        padding: 0.9rem 1rem;
        font-size: 1rem;
        min-height: 50px;
    }

    .home-greeting {
        font-size: 1.5rem !important;
    }
    .home-hero-card {
        flex: 0 0 min(400px, 88%);
        min-height: 200px;
        padding: 1.25rem;
    }
    .home-hero-h3 { font-size: 1.15rem; }
    .home-card { padding: 1.15rem; border-radius: 14px; }
    .home-stat-card { padding: 1rem; }

    .bib-v2-wrap { padding: 0.75rem 0.75rem 1.5rem; }
    .bib-v2-toolbar { flex-direction: column; gap: 0.5rem; }
    .bib-v2-search { min-width: 100%; }
    .bib-v2-title { font-size: 1.3rem; }
    .bib-v2-chips { gap: 0.25rem; }
    .bib-v2-chip { min-height: 30px; padding: 0.25rem 0.55rem; font-size: 0.7rem; }
    .bib-v2-grid-imagenes { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .bib-v2-grid-ideas,
    .bib-v2-grid-copyout,
    .bib-v2-grid-escaletas,
    .bib-v2-grid-hooksbank,
    .bib-v2-grid-inspo { grid-template-columns: 1fr; }

    .home-create-card {
        grid-template-columns: 44px 1fr 18px;
        padding: 1rem;
    }
    .home-create-card-icon {
        width: 44px;
        height: 44px;
        border-radius: 12px;
    }

    .home-template-card {
        padding: 1.25rem;
    }
    .home-template-card-icon {
        width: 48px;
        height: 48px;
    }

    .nivel-cards {
        grid-template-columns: 1fr 1fr;
        gap: 0.6rem;
    }
}

@media (max-width: 400px) {
    .form-card { padding: 1rem; }
    .home-stat-value { font-size: 1.4rem; }
    .home-hero-card {
        flex: 0 0 92%;
        min-height: 180px;
        padding: 1rem;
    }
    .home-create-grid { gap: 0.5rem; }
}


/* ─── FOCUS & ACCESSIBILITY ─── */

.sidebar-nav-item:focus-visible,
.tab-btn:focus-visible,
.generate-btn:focus-visible,
.form-input:focus-visible,
.form-select:focus-visible,
.form-textarea:focus-visible,
.bib-card-btn:focus-visible,
.home-quick-action:focus-visible,
.home-hero-cta:focus-visible,
.home-create-card:focus-visible,
.home-template-card:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.sidebar-nav-item:focus:not(:focus-visible),
.tab-btn:focus:not(:focus-visible),
.generate-btn:focus:not(:focus-visible),
.bib-card-btn:focus:not(:focus-visible),
.home-quick-action:focus:not(:focus-visible),
.home-hero-cta:focus:not(:focus-visible),
.home-create-card:focus:not(:focus-visible),
.home-template-card:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}


/* ─── CONSISTENT DISABLED STATES ─── */

.generate-btn:disabled,
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}


/* ─── TAG BADGES ─── */

.tag-new {
    font-size: 0.58rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    background: linear-gradient(135deg, var(--accent), #9333ea);
    color: #fff;
    letter-spacing: 0.6px;
    line-height: 1;
}


/* ═══════════════════════════════════════════════════
   EMBUDO DIAGNOSTICO V2 — Redesigned output
   ═══════════════════════════════════════════════════ */

.diag-v2 {
    max-width: 800px;
    margin: 0 auto;
}

/* Action bar */
.diag-v2-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-bottom: 1rem;
}
.diag-v2-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--accent, #7C5CFC);
    background: var(--accent, #7C5CFC);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.diag-v2-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 92, 252, 0.3);
}
.diag-v2-action-btn i { width: 15px; height: 15px; }
.diag-v2-action-secondary {
    background: transparent;
    color: var(--text, #fff);
    border-color: var(--border, rgba(0,0,0,0.12));
}
.diag-v2-action-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: none;
}
.diag-v2-action-saved {
    background: #22c55e !important;
    border-color: #22c55e !important;
    pointer-events: none;
}

/* Hero */
.diag-v2-hero {
    background: linear-gradient(135deg, rgba(124, 92, 252, 0.12), rgba(59, 130, 246, 0.08));
    border: 1px solid rgba(124, 92, 252, 0.2);
    border-radius: 14px;
    padding: 2rem 2rem 1.5rem;
    text-align: center;
    margin-bottom: 1.5rem;
}
.diag-v2-cat {
    display: inline-block;
    background: rgba(124, 92, 252, 0.2);
    color: var(--accent, #7C5CFC);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.75rem;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 0.75rem;
}
.diag-v2-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text, #fff);
    margin: 0 0 0.4rem;
    line-height: 1.25;
    letter-spacing: -0.01em;
}
.diag-v2-tipo {
    display: inline-block;
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    margin-bottom: 0.75rem;
}
.diag-v2-desc {
    color: var(--text-muted, #6b7280);
    font-size: 0.9rem;
    line-height: 1.6;
    max-width: 580px;
    margin: 0 auto;
}
.diag-v2-meta-badges {
    display: flex;
    justify-content: center;
    gap: 0.6rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}
.diag-v2-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.7rem;
    border-radius: 8px;
    background: rgba(0,0,0,0.04);
    border: 1px solid rgba(0,0,0,0.08);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted, #6b7280);
}
.diag-v2-badge i { width: 13px; height: 13px; color: var(--badge-color, var(--accent)); }

/* Sections */
.diag-v2-section {
    background: var(--surface-2, rgba(0,0,0,0.02));
    border: 1px solid var(--border, rgba(0,0,0,0.08));
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}
.diag-v2-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text, #fff);
    margin: 0 0 1.25rem;
}
.diag-v2-section-title i { width: 18px; height: 18px; color: var(--accent); }

/* Timeline (vertical steps) */
.diag-v2-timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.diag-v2-step {
    display: flex;
    gap: 1rem;
    position: relative;
}
.diag-v2-step-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    width: 36px;
}
.diag-v2-step-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--step-color, var(--accent));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.8rem;
    flex-shrink: 0;
    z-index: 1;
}
.diag-v2-step-line {
    width: 2px;
    flex: 1;
    min-height: 20px;
    background: linear-gradient(to bottom, var(--step-color, var(--accent)), rgba(0,0,0,0.06));
    margin: 4px 0;
}
.diag-v2-step-content {
    flex: 1;
    padding-bottom: 1.25rem;
}
.diag-v2-step-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.3rem;
}
.diag-v2-step-header i { width: 16px; height: 16px; flex-shrink: 0; }
.diag-v2-step-header strong {
    font-size: 0.9rem;
    color: var(--text, #fff);
}
.diag-v2-step-content p {
    margin: 0;
    font-size: 0.84rem;
    color: var(--text-muted, #6b7280);
    line-height: 1.55;
    padding-left: 20px;
}

/* Porque funciona */
.diag-v2-porque-text {
    font-size: 0.88rem;
    color: var(--text-muted, #6b7280);
    line-height: 1.7;
    white-space: pre-line;
}

/* Tools grid */
.diag-v2-tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
}
.diag-v2-tool-card {
    background: rgba(0,0,0,0.02);
    border: 1px solid var(--border, rgba(0,0,0,0.08));
    border-radius: 10px;
    padding: 0.85rem;
    transition: border-color 0.15s;
}
.diag-v2-tool-card:hover {
    border-color: rgba(124, 92, 252, 0.3);
}
.diag-v2-tool-esencial {
    border-color: rgba(124, 92, 252, 0.25);
    background: rgba(124, 92, 252, 0.04);
}
.diag-v2-tool-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}
.diag-v2-tool-header strong {
    font-size: 0.85rem;
    color: var(--text, #fff);
}
.diag-v2-tool-badge {
    font-size: 0.62rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--accent, #7C5CFC);
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.diag-v2-tool-badge-rec {
    background: rgba(0,0,0,0.08);
    color: var(--text-muted);
}
.diag-v2-tool-card p {
    margin: 0;
    font-size: 0.78rem;
    color: var(--text-muted, #6b7280);
    line-height: 1.45;
}

/* Requisitos */
.diag-v2-requisitos {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.diag-v2-req {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.84rem;
    color: var(--text-muted, #6b7280);
    line-height: 1.5;
}
.diag-v2-req i {
    width: 16px;
    height: 16px;
    color: #22c55e;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Métricas */
.diag-v2-metricas-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}
.diag-v2-metrica {
    background: rgba(124, 92, 252, 0.05);
    border: 1px solid rgba(124, 92, 252, 0.1);
    border-radius: 8px;
    padding: 0.7rem 0.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 70px;
}
.diag-v2-metrica-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent, #7C5CFC);
    margin-bottom: 0.2rem;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.diag-v2-metrica-label {
    font-size: 0.65rem;
    color: var(--text-muted, #6b7280);
    font-weight: 500;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Alternativa */
.diag-v2-alt-card {
    background: rgba(0,0,0,0.02);
    border: 1px solid var(--border, rgba(0,0,0,0.08));
    border-radius: 10px;
    padding: 1rem;
}
.diag-v2-alt-card strong {
    font-size: 0.9rem;
    color: var(--text, #fff);
}
.diag-v2-alt-card p {
    margin: 0.4rem 0 0;
    font-size: 0.82rem;
    color: var(--text-muted, #6b7280);
    line-height: 1.5;
}
.diag-v2-alt-reason {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
    font-style: italic;
    opacity: 0.75;
    margin-top: 0.6rem !important;
}
.diag-v2-alt-reason i { width: 14px; height: 14px; flex-shrink: 0; margin-top: 2px; color: var(--accent); }

/* Diagnóstico del proceso actual */
.diag-v2-proceso-estado {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    border-radius: 8px;
    background: color-mix(in srgb, var(--estado-color) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--estado-color) 25%, transparent);
    margin-bottom: 0.75rem;
}
.diag-v2-proceso-estado i { width: 18px; height: 18px; color: var(--estado-color); }
.diag-v2-proceso-estado strong { font-size: 0.88rem; color: var(--estado-color); }
.diag-v2-proceso-veredicto {
    font-size: 0.9rem;
    color: var(--text, #fff);
    line-height: 1.6;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(0,0,0,0.02);
    border-radius: 8px;
    border-left: 3px solid var(--accent);
}
.diag-v2-proceso-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.65rem;
}
.diag-v2-proceso-item {
    padding: 0.85rem;
    border-radius: 10px;
    border: 1px solid var(--border, rgba(0,0,0,0.08));
    background: rgba(0,0,0,0.02);
}
.diag-v2-proceso-item-header {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.4rem;
}
.diag-v2-proceso-item-header i { width: 15px; height: 15px; }
.diag-v2-proceso-item-header strong { font-size: 0.8rem; }
.diag-v2-proceso-item p { margin: 0; font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }
.diag-v2-proceso-bien .diag-v2-proceso-item-header i { color: #22c55e; }
.diag-v2-proceso-bien .diag-v2-proceso-item-header strong { color: #22c55e; }
.diag-v2-proceso-bien { border-color: rgba(34, 197, 94, 0.2); }
.diag-v2-proceso-mejorar .diag-v2-proceso-item-header i { color: #eab308; }
.diag-v2-proceso-mejorar .diag-v2-proceso-item-header strong { color: #eab308; }
.diag-v2-proceso-mejorar { border-color: rgba(234, 179, 8, 0.2); }
.diag-v2-proceso-cambiar .diag-v2-proceso-item-header i { color: #ef4444; }
.diag-v2-proceso-cambiar .diag-v2-proceso-item-header strong { color: #ef4444; }
.diag-v2-proceso-cambiar { border-color: rgba(239, 68, 68, 0.2); }

/* Mobile */
@media (max-width: 768px) {
    .diag-v2-hero { padding: 1.25rem; }
    .diag-v2-title { font-size: 1.2rem; }
    .diag-v2-desc { font-size: 0.84rem; }
    .diag-v2-section { padding: 1rem; }
    .diag-v2-actions { justify-content: stretch; }
    .diag-v2-action-btn { flex: 1; justify-content: center; font-size: 0.78rem; padding: 0.5rem 0.6rem; }
    .diag-v2-tools-grid { grid-template-columns: 1fr; }
    .diag-v2-metricas-grid { grid-template-columns: repeat(2, 1fr); }
    .diag-v2-metrica-value { font-size: 0.85rem; }
    .diag-v2-step-content p { padding-left: 0; }
    .diag-v2-proceso-grid { grid-template-columns: 1fr; }
}


/* ── Escalera de Valor V2 — Vertical ascending stack ── */
.escalera-v2-stack {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 1rem 0 1.5rem;
    padding-left: 0.25rem;
}
.escalera-v2-step {
    display: flex;
    gap: 1.1rem;
    position: relative;
}
.escalera-v2-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    width: 40px;
}
.escalera-v2-num {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--step-color, #7C5CFC);
    color: #fff;
    font-weight: 800;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    z-index: 1;
    box-shadow: 0 0 0 4px rgba(26, 26, 46, 1), 0 0 16px color-mix(in srgb, var(--step-color, #7C5CFC) 35%, transparent);
    transition: transform 0.2s, box-shadow 0.2s;
}
.escalera-v2-step:hover .escalera-v2-num {
    transform: scale(1.08);
    box-shadow: 0 0 0 4px rgba(26, 26, 46, 1), 0 0 22px color-mix(in srgb, var(--step-color, #7C5CFC) 50%, transparent);
}
.escalera-v2-connector {
    width: 2px;
    flex: 1;
    min-height: 20px;
    background: repeating-linear-gradient(
        to bottom,
        color-mix(in srgb, var(--step-color, #7C5CFC) 40%, transparent) 0px,
        color-mix(in srgb, var(--step-color, #7C5CFC) 40%, transparent) 6px,
        transparent 6px,
        transparent 10px
    );
}
.escalera-v2-content {
    flex: 1;
    background: linear-gradient(135deg, rgba(244,245,251,0.95), rgba(20, 20, 38, 0.85));
    border: 1px solid rgba(0,0,0,0.06);
    border-left: 3px solid var(--step-color, #7C5CFC);
    border-radius: 12px;
    padding: 1.15rem 1.3rem;
    margin-bottom: 0.85rem;
    transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
    position: relative;
    overflow: hidden;
}
.escalera-v2-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, var(--step-color, #7C5CFC), transparent 60%);
    opacity: 0.3;
}
.escalera-v2-content:hover {
    border-color: var(--step-color, #7C5CFC);
    box-shadow: 0 4px 20px color-mix(in srgb, var(--step-color, #7C5CFC) 12%, transparent);
    background: linear-gradient(135deg, rgba(244,245,251,0.98), rgba(22, 22, 42, 0.9));
}
.escalera-v2-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
}
.escalera-v2-tipo {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--step-color, #7C5CFC);
    background: color-mix(in srgb, var(--step-color, #7C5CFC) 12%, transparent);
    padding: 0.2rem 0.6rem;
    border-radius: 5px;
    border: 1px solid color-mix(in srgb, var(--step-color, #7C5CFC) 18%, transparent);
}
.escalera-v2-precio {
    font-size: 1.1rem;
    font-weight: 800;
    color: #fff;
    white-space: nowrap;
    text-shadow: 0 0 20px color-mix(in srgb, var(--step-color, #7C5CFC) 30%, transparent);
}
.escalera-v2-nombre {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 0.35rem;
    line-height: 1.35;
}
.escalera-v2-desc {
    font-size: 0.8rem;
    color: var(--text-muted, #6b7280);
    line-height: 1.55;
    margin: 0 0 0.6rem;
}
.escalera-v2-incluye {
    margin-bottom: 0.5rem;
    padding: 0.6rem 0.7rem;
    background: rgba(0,0,0,0.02);
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.04);
}
.escalera-v2-incluye strong {
    font-size: 0.68rem;
    color: var(--text-muted, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 0.3rem;
}
.escalera-v2-incluye ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.escalera-v2-incluye li {
    font-size: 0.78rem;
    color: var(--text-secondary, #6b7280);
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    line-height: 1.45;
}
.escalera-v2-incluye li svg {
    width: 14px;
    height: 14px;
    color: var(--step-color, #34d399);
    flex-shrink: 0;
    margin-top: 2px;
}
.escalera-v2-objetivo {
    font-size: 0.76rem;
    color: var(--text-muted, #6b7280);
    margin: 0.5rem 0 0.2rem;
    line-height: 1.45;
    font-style: italic;
    padding-left: 0.5rem;
    border-left: 2px solid color-mix(in srgb, var(--step-color, #7C5CFC) 25%, transparent);
}
.escalera-v2-obj-label {
    font-weight: 600;
    font-style: normal;
    color: var(--text-secondary, #6b7280);
}
.escalera-v2-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
    padding-top: 0.6rem;
    border-top: 1px solid rgba(0,0,0,0.04);
}
.escalera-v2-actions .oferta-action-btn {
    font-size: 0.72rem;
    padding: 0.4rem 0.75rem;
    border-radius: 7px;
}
.escalera-v2-actions .oferta-action-btn svg {
    width: 13px;
    height: 13px;
}
@media (max-width: 640px) {
    .escalera-v2-stack { padding-left: 0; }
    .escalera-v2-indicator { width: 32px; }
    .escalera-v2-num { width: 32px; height: 32px; font-size: 0.8rem; }
    .escalera-v2-content { padding: 0.9rem 1rem; border-radius: 10px; }
    .escalera-v2-precio { font-size: 0.95rem; }
    .escalera-v2-nombre { font-size: 0.92rem; }
    .escalera-v2-incluye { padding: 0.5rem 0.55rem; }
}


/* ── Guión de referencia field in Lluvia de Hooks ── */
#hrGuionBaseField .pm-textarea {
    font-size: 0.8rem;
    line-height: 1.5;
    resize: vertical;
    min-height: 80px;
    max-height: 200px;
    font-family: inherit;
}
.hr-guion-clear-btn {
    background: none;
    border: none;
    color: var(--text-muted, #6b7280);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
    display: flex;
    align-items: center;
}
.hr-guion-clear-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}
.hr-guion-clear-btn svg {
    width: 14px;
    height: 14px;
}
.pm-optional {
    font-weight: 400;
    font-size: 0.7rem;
    color: var(--text-muted, #6b7280);
}


/* ============================================================
   IG REELS GRID — Instagram scraper results
   ============================================================ */
.ig-results-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #374151;
    font-size: 16px;
    font-weight: 600;
}
.ig-results-title i { color: #E1306C; width: 20px; height: 20px; }
.ig-results-title h3 { margin: 0; font-size: inherit; font-weight: inherit; }
.ig-results-count {
    font-size: 12px;
    color: #475569;
    font-weight: 400;
    background: rgba(100, 116, 139, 0.15);
    padding: 2px 8px;
    border-radius: 10px;
}
.ig-results-sub {
    color: #4b5563;
    font-size: 13px;
    margin: 0 0 16px 0;
    line-height: 1.5;
}
.ig-results-sub strong { color: #4b5563; }

/* Sort filter tabs for IG analyzer */
.ig-sort-bar {
    position: relative;
    z-index: 5;
    margin: 0 0 16px 0;
}
.ig-sort-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.ig-sort-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border-radius: 20px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(148, 163, 184, 0.08);
    color: #4b5563;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}
.ig-sort-tab:hover {
    background: rgba(168, 85, 247, 0.15);
    border-color: rgba(168, 85, 247, 0.4);
    color: #c084fc;
}
.ig-sort-tab.active {
    background: rgba(168, 85, 247, 0.2);
    border-color: #a855f7;
    color: #c084fc;
    font-weight: 600;
}
.ig-sort-tab svg,
.ig-sort-tab i {
    width: 14px;
    height: 14px;
}
.ig-sort-hint {
    color: #475569;
    font-size: 12px;
    margin: 0;
    line-height: 1.5;
}
.ig-sort-hint strong {
    color: #4b5563;
}
@media (max-width: 600px) {
    .ig-sort-tabs {
        gap: 6px;
    }
    .ig-sort-tab {
        padding: 6px 12px;
        font-size: 12px;
    }
}

.ig-reels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
@media (max-width: 600px) {
    .ig-reels-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

.ig-reel-card {
    background: linear-gradient(135deg, rgba(244,245,251,0.95), rgba(22, 22, 40, 0.9));
    border: 1px solid rgba(124, 92, 252, 0.12);
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}
.ig-reel-card:hover {
    transform: translateY(-3px);
    border-color: rgba(225, 48, 108, 0.4);
    box-shadow: 0 8px 24px rgba(225, 48, 108, 0.12);
}

.ig-reel-thumb {
    position: relative;
    aspect-ratio: 9 / 16;
    max-height: 320px;
    overflow: hidden;
    background: rgba(255,255,255,0.8);
}
.ig-reel-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.ig-reel-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #475569;
}
.ig-reel-thumb-placeholder i { width: 40px; height: 40px; }

.ig-reel-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}
.ig-reel-play i { color: #fff; width: 20px; height: 20px; margin-left: 2px; }
.ig-reel-card:hover .ig-reel-play { opacity: 1; }

.ig-reel-stats {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 24px 10px 8px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: #fff;
    font-weight: 500;
}
.ig-reel-stats span {
    display: flex;
    align-items: center;
    gap: 4px;
}
.ig-reel-stats i { width: 13px; height: 13px; }

.ig-reel-info {
    padding: 10px 12px 6px;
    flex: 1;
}
.ig-reel-caption {
    color: #4b5563;
    font-size: 12px;
    line-height: 1.45;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.ig-reel-time {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: #475569;
}

.ig-reel-analyze-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 6px 10px 10px;
    padding: 8px 0;
    background: linear-gradient(135deg, #7C5CFC, #E1306C);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.15s ease;
}
.ig-reel-analyze-btn:hover {
    opacity: 0.9;
    transform: scale(1.02);
}
.ig-reel-analyze-btn i { width: 15px; height: 15px; }


/* ============================================
   CREATIVE STUDIO — Image Chat Module
   ============================================ */

/* Main container */
.cs-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px);
    max-width: 900px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Header */
.cs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0 12px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    flex-shrink: 0;
}
.cs-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.cs-header-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #a855f7 0%, #6366f1 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}
.cs-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: #2b3040;
    margin: 0;
}
.cs-header p {
    font-size: 13px;
    color: #475569;
    margin: 2px 0 0;
}
.cs-history-btn {
    background: rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.08);
    color: #4b5563;
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
}
.cs-history-btn:hover {
    background: rgba(168,85,247,0.15);
    border-color: rgba(168,85,247,0.3);
    color: #c084fc;
}

/* Brand selector */
.cs-brand-bar {
    display: flex;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    flex-shrink: 0;
    flex-wrap: wrap;
}
.cs-brand-select {
    background: rgba(0,0,0,0.04);
    border: 1px solid rgba(0,0,0,0.08);
    color: #374151;
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 13px;
    min-width: 160px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}
.cs-brand-select:focus {
    outline: none;
    border-color: #a855f7;
}
.cs-brand-select option {
    background: #f4f5fb;
    color: #374151;
}

/* Messages area */
.cs-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}
.cs-messages::-webkit-scrollbar {
    width: 4px;
}
.cs-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 4px;
}

/* Message bubbles */
.cs-msg {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: csMsgIn 0.25s ease;
}
@keyframes csMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.cs-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.cs-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}
.cs-msg.assistant .cs-msg-avatar {
    background: linear-gradient(135deg, #a855f7, #6366f1);
}
.cs-msg.user .cs-msg-avatar {
    background: rgba(168,85,247,0.2);
    color: #c084fc;
}
.cs-msg-bubble {
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.6;
    color: #374151;
}
.cs-msg.assistant .cs-msg-bubble {
    background: rgba(0,0,0,0.04);
    border: 1px solid rgba(0,0,0,0.06);
    border-top-left-radius: 4px;
}
.cs-msg.user .cs-msg-bubble {
    background: linear-gradient(135deg, rgba(168,85,247,0.25), rgba(99,102,241,0.2));
    border: 1px solid rgba(168,85,247,0.3);
    border-top-right-radius: 4px;
}
.cs-msg-bubble strong { color: #c084fc; font-weight: 600; }
.cs-msg-bubble ul, .cs-msg-bubble ol { margin: 6px 0; padding-left: 20px; }
.cs-msg-bubble li { margin: 3px 0; }
.cs-msg-bubble p { margin: 0 0 8px; }
.cs-msg-bubble p:last-child { margin: 0; }

/* Typing indicator */
.cs-typing {
    display: flex;
    gap: 4px;
    padding: 14px 18px;
}
.cs-typing span {
    width: 6px;
    height: 6px;
    background: #64748b;
    border-radius: 50%;
    animation: csTyping 1.2s infinite;
}
.cs-typing span:nth-child(2) { animation-delay: 0.2s; }
.cs-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes csTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Reference cards in chat */
.cs-refs-strip {
    display: flex;
    gap: 8px;
    padding: 8px 0;
    overflow-x: auto;
    max-width: 100%;
}
.cs-ref-card {
    width: 80px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.08);
    position: relative;
}
.cs-ref-card img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    display: block;
}
.cs-ref-card .cs-ref-label {
    font-size: 9px;
    color: #4b5563;
    padding: 3px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: rgba(0,0,0,0.6);
}
.cs-ref-card .cs-ref-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    color: #ef4444;
    font-size: 10px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Generated image in chat */
.cs-gen-image {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(168,85,247,0.2);
    margin-top: 8px;
    max-width: 400px;
}
.cs-gen-image img {
    width: 100%;
    display: block;
}
.cs-gen-image-actions {
    display: flex;
    gap: 6px;
    padding: 8px;
    background: rgba(0,0,0,0.05);
}
.cs-gen-image-actions button {
    flex: 1;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.08);
    background: rgba(0,0,0,0.04);
    color: #4b5563;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.15s;
}
.cs-gen-image-actions button:hover {
    background: rgba(168,85,247,0.15);
    color: #c084fc;
    border-color: rgba(168,85,247,0.3);
}

/* Model picker inline */
.cs-model-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.cs-model-btn {
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,0.1);
    background: rgba(0,0,0,0.04);
    color: #374151;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.cs-model-btn:hover {
    border-color: #a855f7;
    background: rgba(168,85,247,0.1);
}
.cs-model-btn .cs-model-cost {
    color: #a855f7;
    font-weight: 600;
}

/* Input area */
.cs-input-area {
    padding: 12px 0 16px;
    border-top: 1px solid rgba(0,0,0,0.06);
    flex-shrink: 0;
}
.cs-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.cs-attach-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,0.08);
    background: rgba(0,0,0,0.04);
    color: #4b5563;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
    position: relative;
}
.cs-attach-btn:hover {
    background: rgba(168,85,247,0.15);
    color: #c084fc;
    border-color: rgba(168,85,247,0.3);
}
.cs-attach-btn .cs-attach-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #a855f7;
    color: white;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}
.cs-input-wrap {
    flex: 1;
    position: relative;
}
.cs-input {
    width: 100%;
    resize: none;
    border: 1px solid rgba(0,0,0,0.08);
    background: rgba(0,0,0,0.04);
    color: #374151;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.5;
    min-height: 42px;
    max-height: 120px;
    font-family: inherit;
    box-sizing: border-box;
}
.cs-input:focus {
    outline: none;
    border-color: rgba(168,85,247,0.4);
}
.cs-input::placeholder {
    color: #475569;
}
.cs-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #a855f7, #7c3aed);
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}
.cs-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(168,85,247,0.3);
}
.cs-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Suggestions */
.cs-suggestions {
    display: flex;
    gap: 8px;
    padding: 6px 0;
    flex-wrap: wrap;
}
.cs-suggestion {
    padding: 7px 14px;
    border-radius: 20px;
    border: 1px solid rgba(168,85,247,0.2);
    background: rgba(168,85,247,0.06);
    color: #c084fc;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.cs-suggestion:hover {
    background: rgba(168,85,247,0.15);
    border-color: rgba(168,85,247,0.4);
}

/* ============================================
   REFERENCE PICKER MODAL
   ============================================ */
.cs-picker-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: csFadeIn 0.2s ease;
}
@keyframes csFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.cs-picker {
    width: 90vw;
    max-width: 1000px;
    max-height: 85vh;
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: csSlideUp 0.25s ease;
}
@keyframes csSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.cs-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}
.cs-picker-header h3 {
    font-size: 16px;
    color: #2b3040;
    margin: 0;
}
.cs-picker-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: rgba(0,0,0,0.05);
    color: #4b5563;
    font-size: 18px;
    cursor: pointer;
}
.cs-picker-filters {
    display: flex;
    gap: 10px;
    padding: 12px 20px;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    flex-wrap: wrap;
}
.cs-picker-search {
    flex: 1;
    min-width: 200px;
    background: rgba(0,0,0,0.04);
    border: 1px solid rgba(0,0,0,0.08);
    color: #374151;
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 13px;
}
.cs-picker-search:focus {
    outline: none;
    border-color: rgba(168,85,247,0.4);
}
.cs-picker-search::placeholder {
    color: #475569;
}
.cs-picker-select {
    background: rgba(0,0,0,0.04);
    border: 1px solid rgba(0,0,0,0.08);
    color: #374151;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13px;
}
.cs-picker-select option {
    background: #f4f5fb;
    color: #374151;
}
.cs-picker-grid {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    align-content: start;
}
.cs-picker-grid::-webkit-scrollbar {
    width: 4px;
}
.cs-picker-grid::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 4px;
}
.cs-picker-item {
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(0,0,0,0.06);
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}
.cs-picker-item:hover {
    border-color: rgba(168,85,247,0.3);
    transform: translateY(-2px);
}
.cs-picker-item.selected {
    border-color: #a855f7;
    box-shadow: 0 0 12px rgba(168,85,247,0.3);
}
.cs-picker-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}
.cs-picker-item-info {
    padding: 6px 8px;
    background: rgba(0,0,0,0.5);
}
.cs-picker-item-name {
    font-size: 10px;
    color: #4b5563;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cs-picker-item-fmt {
    font-size: 9px;
    color: #a855f7;
    margin-top: 2px;
}
.cs-picker-item .cs-check {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #a855f7;
    color: white;
    font-size: 12px;
    display: none;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}
.cs-picker-item.selected .cs-check {
    display: flex;
}
.cs-picker-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid rgba(0,0,0,0.06);
}
.cs-picker-count {
    font-size: 13px;
    color: #4b5563;
}
.cs-picker-count strong {
    color: #a855f7;
}
.cs-picker-attach-btn {
    padding: 10px 24px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #a855f7, #7c3aed);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.cs-picker-attach-btn:hover {
    transform: scale(1.03);
    box-shadow: 0 0 20px rgba(168,85,247,0.3);
}
.cs-picker-attach-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* History panel */
.cs-history-panel {
    position: fixed;
    top: 0;
    right: -350px;
    width: 340px;
    height: 100vh;
    background: #ffffff;
    border-left: 1px solid rgba(0,0,0,0.06);
    z-index: 9999;
    transition: right 0.25s ease;
    display: flex;
    flex-direction: column;
}
.cs-history-panel.open {
    right: 0;
}
.cs-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}
.cs-history-header h3 {
    margin: 0;
    font-size: 16px;
    color: #2b3040;
}
.cs-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}
.cs-history-item {
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.12s;
    margin-bottom: 4px;
}
.cs-history-item:hover {
    background: rgba(0,0,0,0.04);
}
.cs-history-item-title {
    font-size: 13px;
    color: #374151;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cs-history-item-meta {
    font-size: 11px;
    color: #475569;
}

/* Loading bar for image generation */
.cs-img-loading {
    background: rgba(168,85,247,0.08);
    border: 1px solid rgba(168,85,247,0.15);
    border-radius: 12px;
    padding: 16px;
    margin-top: 8px;
}
.cs-img-loading-text {
    font-size: 13px;
    color: #c084fc;
    margin-bottom: 10px;
}
.cs-img-loading-bar {
    height: 4px;
    background: rgba(0,0,0,0.06);
    border-radius: 4px;
    overflow: hidden;
}
.cs-img-loading-bar div {
    height: 100%;
    background: linear-gradient(90deg, #a855f7, #6366f1, #a855f7);
    background-size: 200% 100%;
    animation: csLoadBar 1.5s linear infinite;
    width: 60%;
    border-radius: 4px;
}
@keyframes csLoadBar {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* New conversation button */
.cs-new-chat-btn {
    margin: 8px;
    padding: 10px;
    border-radius: 10px;
    border: 1px dashed rgba(168,85,247,0.3);
    background: rgba(168,85,247,0.05);
    color: #c084fc;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s;
}
.cs-new-chat-btn:hover {
    background: rgba(168,85,247,0.12);
    border-color: rgba(168,85,247,0.5);
}

/* History overlay backdrop */
.cs-history-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
    display: none;
}
.cs-history-backdrop.open {
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .cs-container { padding: 0 10px; }
    .cs-msg { max-width: 92%; }
    .cs-picker { width: 95vw; max-height: 90vh; }
    .cs-picker-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
    .cs-gen-image { max-width: 100%; }
    .cs-history-panel { width: 100%; right: -100%; }
}