:root {
    --rpc-brand: #0f766e;
    --rpc-brand-strong: #0a5a54;
    --rpc-brand-soft: #e8f6f3;
    --rpc-brand-soft-2: #f4fbf9;
    --rpc-accent: #1f7a55;
    --rpc-border: #cfe5de;
    --rpc-text: #173a36;
    --rpc-text-soft: #5a7870;
    --rpc-surface: #ffffff;
    --rpc-surface-alt: #f3faf8;
}

.rpc-widget {
    max-width: 960px;
    margin: 32px auto;
    background: var(--rpc-surface);
    border: 1px solid var(--rpc-border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 22px 55px rgba(10, 55, 45, 0.12);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.rpc-selector {
    padding: 34px;
    background:
        linear-gradient(180deg, #ffffff, #f7fbfa);
}

.rpc-selector h2 {
    margin: 0 0 8px;
    font-size: 30px;
    line-height: 1.15;
    letter-spacing: -0.04em;
    color: var(--rpc-text);
}

.rpc-selector-intro {
    margin: 0 0 28px;
    color: var(--rpc-text-soft);
    font-size: 15px;
}

.rpc-persona-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
    gap: 16px;
}

.rpc-persona-card {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    width: 100%;
    padding: 18px;
    border: 1px solid var(--rpc-border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.92);
    cursor: pointer;
    text-align: left;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease;
}

.rpc-persona-card:hover {
    transform: translateY(-3px);
    border-color: rgba(15, 118, 110, 0.35);
    background: #ffffff;
    box-shadow: 0 14px 28px rgba(15, 118, 110, 0.12);
}

.rpc-persona-avatar {
    width: 54px;
    height: 54px;
    border-radius: 999px;
    overflow: hidden;
    background: linear-gradient(135deg, #eef7f4, #f6fbf9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: var(--rpc-brand);
    flex: 0 0 auto;
}

.rpc-persona-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform-origin: center center;
}

.rpc-persona-info strong {
    display: block;
    color: var(--rpc-text);
    font-size: 16px;
    margin-bottom: 2px;
}

.rpc-persona-info em {
    display: block;
    font-style: normal;
    color: var(--rpc-brand);
    font-size: 13px;
    font-weight: 750;
    margin-bottom: 7px;
}

.rpc-persona-info small {
    display: block;
    color: var(--rpc-text-soft);
    line-height: 1.45;
    font-size: 13px;
}

.rpc-chat {
    height: min(760px, 82vh);
    display: flex;
    flex-direction: column;
    background: var(--rpc-surface-alt);
}

.rpc-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.97);
    border-bottom: 1px solid var(--rpc-border);
    backdrop-filter: blur(8px);
}

.rpc-chat-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rpc-back,
.rpc-new-chat {
    border: 0;
    background: #edf3f9;
    color: var(--rpc-text);
    border-radius: 10px;
    padding: 9px 13px;
    font-size: 13px;
    font-weight: 750;
    cursor: pointer;
    transition: background .15s ease, transform .15s ease;
}

.rpc-back:hover,
.rpc-new-chat:hover {
    background: #dfe9f4;
    transform: translateY(-1px);
}

.rpc-new-chat {
    background: var(--rpc-brand-soft);
    color: var(--rpc-brand);
}

.rpc-new-chat:hover {
    background: #d7eee7;
}

.rpc-current-persona {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--rpc-text);
    font-size: 14px;
    min-width: 0;
}

.rpc-current-persona strong {
    display: block;
    line-height: 1.15;
    white-space: nowrap;
}

.rpc-current-persona small {
    display: block;
    color: var(--rpc-text-soft);
    font-size: 12px;
    white-space: nowrap;
}

.rpc-current-persona img,
.rpc-current-persona .rpc-current-initial {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    object-fit: cover;
    box-shadow: 0 0 0 3px var(--rpc-brand-soft);
    flex: 0 0 auto;
}

.rpc-current-persona img {
    transform-origin: center center;
}

.rpc-current-persona .rpc-current-initial {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--rpc-brand-soft);
    color: var(--rpc-brand);
    font-weight: 800;
}

.rpc-messages {
    flex: 1;
    min-height: 0 !important;
    overflow-y: auto;
    padding: 24px 18px;
    scroll-behavior: smooth;
}

.rpc-message {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    align-items: flex-end;
}

.rpc-message.rpc-user {
    justify-content: flex-end;
}

.rpc-message.rpc-bot {
    justify-content: flex-start;
}

.rpc-message-avatar {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--rpc-brand-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    font-weight: 800;
    color: var(--rpc-brand);
    font-size: 13px;
}

.rpc-consent-gate {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 18px;
    border-top: 1px solid #e5e7eb;
    background: linear-gradient(180deg, #f9fcfb, #ffffff);
}

.rpc-consent-gate[hidden] {
    display: none !important;
}

.rpc-consent-gate-copy strong {
    display: block;
    margin-bottom: 4px;
    color: #9a3412;
    font-size: 14px;
}

.rpc-consent-gate-copy p {
    margin: 0;
    color: #7c2d12;
    font-size: 13px;
    line-height: 1.45;
}

.rpc-consent-accept {
    border: 0;
    border-radius: 10px;
    background: var(--rpc-brand);
    color: #ffffff;
    font-weight: 800;
    padding: 11px 16px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s ease, transform .15s ease;
    width: 100%;
    text-align: center;
}

.rpc-consent-accept:hover {
    background: var(--rpc-brand-strong);
    transform: translateY(-1px);
}

.rpc-legal-panel {
    border-top: 1px solid var(--rpc-border);
    background: linear-gradient(180deg, #fbfefd, #eff8f5);
    min-height: 0;
    overflow: hidden;
}

.rpc-privacy-details {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.rpc-privacy-details summary {
    flex: 0 0 auto;
    cursor: pointer;
    list-style: none;
    padding: 14px 18px;
    font-size: 12px;
    font-weight: 700;
    color: var(--rpc-brand-strong);
    background: rgba(15, 118, 110, 0.06);
    border-bottom: 1px solid rgba(15, 118, 110, 0.10);
}

.rpc-privacy-details summary::-webkit-details-marker {
    display: none;
}

.rpc-privacy-details-body {
    min-height: 0;
    padding: 14px 18px 16px;
    font-size: 12px;
    color: var(--rpc-text);
    line-height: 1.62;
    background: rgba(255, 255, 255, 0.94);
    max-height: min(220px, 30vh);
    overflow-y: auto;
    margin-bottom: 8px;
    scrollbar-gutter: stable;
}

.rpc-chat.rpc-consent-required .rpc-messages,
.rpc-chat.rpc-consent-required .rpc-form,
.rpc-chat.rpc-consent-required .rpc-legal-panel {
    display: none !important;
}

.rpc-chat.rpc-consent-required .rpc-consent-gate {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
    justify-content: flex-start !important;
    gap: 10px;
    padding: 14px 14px 12px;
    background: #ffffff;
    overflow: hidden !important;
}

.rpc-consent-gate-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 4px;
}

.rpc-consent-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 2px 0 2px;
}

.rpc-consent-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(15, 118, 110, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    line-height: 1;
    margin-bottom: 6px;
    border: 1px solid rgba(15, 118, 110, 0.15);
}

.rpc-consent-hero-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--rpc-brand-strong, #0f766e);
}

/* AI Notice Card */
.rpc-ai-notice-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rpc-ai-notice-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.rpc-ai-notice-icon {
    font-size: 14px;
    line-height: 1;
}

.rpc-ai-notice-title {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
}

.rpc-ai-notice-text {
    font-size: 13px;
    line-height: 1.45;
    color: #475569;
}

/* Consent Statement */
.rpc-consent-statement {
    padding: 2px 0;
}

.rpc-consent-primary-text {
    margin: 0;
    font-size: 13px;
    font-weight: 400;
    color: #64748b;
    line-height: 1.45;
}

.rpc-consent-actions {
    flex: 0 0 auto;
    padding-top: 6px;
    margin-top: 2px;
    background: transparent;
}

.rpc-privacy-details-body p {
    margin: 0 0 10px;
}

.rpc-privacy-details-body .rpc-privacy-intro {
    color: var(--rpc-text-soft);
}

.rpc-privacy-item {
    display: grid;
    gap: 3px;
    margin: 0 0 12px;
}

.rpc-privacy-item:last-child {
    margin-bottom: 0;
}

.rpc-privacy-item span {
    display: block;
    color: var(--rpc-text);
    line-height: 1.42;
}

.rpc-privacy-details-body a {
    color: var(--rpc-brand);
    font-weight: 700;
    text-underline-offset: 3px;
}

.rpc-privacy-details-body strong {
    color: var(--rpc-brand-strong);
    line-height: 1.25;
}

.rpc-consent-withdraw {
    display: inline;
    margin-left: 8px;
    color: var(--rpc-brand-strong);
    font-size: 12px;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.rpc-consent-withdraw:hover {
    color: var(--rpc-brand);
}

.rpc-consent-withdraw:focus-visible {
    outline: 2px solid rgba(15, 118, 110, 0.28);
    outline-offset: 2px;
    border-radius: 2px;
}

.rpc-message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform-origin: center center;
}

.rpc-bubble {
    max-width: min(690px, 78%);
    padding: 13px 16px;
    border-radius: 14px;
    font-size: 15px;
    line-height: 1.58;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.rpc-message.rpc-notice .rpc-bubble {
    background: linear-gradient(180deg, #eff8f5, #ffffff);
    border: 1px solid rgba(15, 118, 110, 0.14);
    color: var(--rpc-text);
    font-size: 13px;
    line-height: 1.55;
}

.rpc-message.rpc-notice .rpc-bubble strong:first-child {
    color: var(--rpc-brand-strong);
}

.rpc-bot .rpc-bubble {
    background: #ffffff;
    color: var(--rpc-text);
    border: 1px solid var(--rpc-border);
    border-bottom-left-radius: 7px;
    box-shadow: 0 8px 22px rgba(10, 55, 45, 0.07);
}

.rpc-user .rpc-bubble {
    background: linear-gradient(135deg, var(--rpc-brand), #1b8d6b);
    color: #ffffff;
    border-bottom-right-radius: 7px;
    box-shadow: 0 9px 22px rgba(15, 118, 110, 0.24);
}

.rpc-bubble p {
    margin: 0 0 10px;
}

.rpc-bubble p:last-child {
    margin-bottom: 0;
}

.rpc-bubble ul,
.rpc-bubble ol {
    margin: 8px 0 8px 22px;
    padding: 0;
}

.rpc-bubble li {
    margin: 4px 0;
}

.rpc-bubble code {
    padding: 2px 5px;
    border-radius: 6px;
    background: #f3f4f6;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: .92em;
}

.rpc-user .rpc-bubble code {
    background: rgba(255, 255, 255, 0.18);
}

.rpc-bubble a {
    color: var(--rpc-brand);
    font-weight: 650;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.rpc-user .rpc-bubble a {
    color: #ffffff;
}

.rpc-typing .rpc-bubble {
    color: #6b7280;
}

.rpc-typing-dots {
    display: inline-flex;
    gap: 4px;
    vertical-align: middle;
    margin-left: 3px;
}

.rpc-typing-dots span {
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: currentColor;
    opacity: .35;
    animation: rpcTyping 1s infinite ease-in-out;
}

.rpc-typing-dots span:nth-child(2) {
    animation-delay: .15s;
}

.rpc-typing-dots span:nth-child(3) {
    animation-delay: .3s;
}

@keyframes rpcTyping {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: .35;
    }
    40% {
        transform: translateY(-3px);
        opacity: .9;
    }
}

.rpc-form {
    display: flex;
    gap: 10px;
    padding: 14px;
    background: #ffffff;
    border-top: 1px solid var(--rpc-border);
}

.rpc-form.rpc-form-disabled {
    opacity: .72;
}

.rpc-form textarea {
    flex: 1;
    min-height: 48px;
    max-height: 140px;
    resize: vertical;
    border: 1px solid #c8d6e6;
    border-radius: 12px;
    padding: 13px 14px;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.4;
    color: var(--rpc-text);
    background: #ffffff;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.rpc-form textarea:focus {
    border-color: #7ea7d7;
    box-shadow: 0 0 0 4px rgba(31, 95, 174, 0.16);
}

.rpc-form button {
    align-self: flex-end;
    border: 0;
    border-radius: 12px;
    background: var(--rpc-brand);
    color: #ffffff;
    font-weight: 800;
    padding: 0 21px;
    min-height: 48px;
    cursor: pointer;
    transition: background .15s ease, transform .15s ease, opacity .15s ease;
}

.rpc-form button:hover {
    background: var(--rpc-brand-strong);
    transform: translateY(-1px);
}

.rpc-form button:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
}

.rpc-login-required {
    max-width: 720px;
    margin: 24px auto;
    padding: 18px 20px;
    border-radius: 16px;
    background: #fdf6ea;
    border: 1px solid #efd4a6;
    color: #9a3412;
    font-weight: 650;
}

.rpc-messages::-webkit-scrollbar {
    width: 10px;
}

.rpc-messages::-webkit-scrollbar-track {
    background: transparent;
}

.rpc-messages::-webkit-scrollbar-thumb {
    background: #b9d4cc;
    border-radius: 999px;
    border: 3px solid var(--rpc-surface-alt);
}

@media (max-width: 700px) {
    .rpc-widget {
        margin: 0;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        min-height: 100vh;
    }

    .rpc-chat {
        height: 100vh;
    }

    .rpc-selector {
        padding: 24px 16px;
    }

    .rpc-selector h2 {
        font-size: 25px;
    }

    .rpc-chat-header {
        align-items: flex-start;
        flex-direction: column-reverse;
    }

    .rpc-chat-actions {
        width: 100%;
        justify-content: space-between;
    }

    .rpc-bubble {
        max-width: 84%;
        font-size: 14px;
    }

    .rpc-form {
        padding: 10px;
    }

    .rpc-form button {
        padding: 0 14px;
    }

    .rpc-consent-gate {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* === MODO FLOTANTE DEL CHATBOT === */

.rpc-widget.rpc-floating-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 999999;
    width: min(430px, calc(100vw - 32px));
    max-width: none;
    margin: 0;
    border-radius: 16px;
    overflow: hidden;
}

.rpc-widget.rpc-floating-widget.rpc-collapsed {
    width: auto;
    min-height: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    overflow: visible;
}

.rpc-widget.rpc-floating-widget.rpc-collapsed .rpc-selector,
.rpc-widget.rpc-floating-widget.rpc-collapsed .rpc-chat {
    display: none !important;
}

.rpc-launcher {
    display: none;
}

.rpc-widget.rpc-floating-widget.rpc-collapsed .rpc-launcher {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: 999px;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--rpc-brand), #1b8d6b);
    color: #ffffff;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 14px 30px rgba(15, 118, 110, 0.28);
    transition: transform .16s ease, box-shadow .16s ease;
}

.rpc-widget.rpc-floating-widget.rpc-collapsed .rpc-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 36px rgba(15, 118, 110, 0.34);
}

.rpc-launcher-icon {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.rpc-launcher-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.rpc-launcher-text {
    line-height: 1;
    white-space: nowrap;
}

.rpc-widget.rpc-floating-widget:not(.rpc-collapsed) .rpc-launcher {
    display: none;
}

.rpc-widget.rpc-floating-widget .rpc-selector {
    max-height: min(720px, calc(100vh - 48px));
    overflow-y: auto;
}

.rpc-widget.rpc-floating-widget .rpc-selector h2 {
    padding-right: 92px;
}

.rpc-widget.rpc-floating-widget .rpc-persona-grid {
    grid-template-columns: 1fr;
}

.rpc-widget.rpc-floating-widget .rpc-chat {
    width: 100%;
    height: min(720px, calc(100vh - 48px));
}

.rpc-selector-minimize {
    float: right;
    border: 0;
    border-radius: 999px;
    background: #eef2ff;
    color: #4338ca;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 750;
    cursor: pointer;
    margin-left: 12px;
}

.rpc-selector-minimize:hover {
    background: #e0e7ff;
}

.rpc-minimize {
    border: 0;
    background: #f3f4f6;
    color: #374151;
    border-radius: 999px;
    padding: 9px 13px;
    font-size: 13px;
    font-weight: 750;
    cursor: pointer;
    transition: background .15s ease, transform .15s ease;
}

.rpc-minimize:hover {
    background: #e5e7eb;
    transform: translateY(-1px);
}

@media (max-width: 700px) {
    .rpc-widget.rpc-floating-widget {
        right: 10px;
        left: 10px;
        bottom: 10px;
        width: auto;
        max-width: none;
        min-height: 0;
        border-radius: 22px;
    }

    .rpc-widget.rpc-floating-widget.rpc-collapsed {
        left: auto;
        right: 18px;
        bottom: 18px;
        width: auto;
    }

    .rpc-widget.rpc-floating-widget .rpc-chat {
        height: min(82vh, 680px);
    }

    .rpc-widget.rpc-floating-widget .rpc-selector {
        max-height: min(82vh, 680px);
    }

    .rpc-widget.rpc-floating-widget.rpc-collapsed .rpc-launcher {
        width: 58px;
        height: 58px;
        padding: 0;
        justify-content: center;
    }

    .rpc-launcher-text {
        display: none;
    }
}

/* === CORRECCION: selector visible en pagina y chat flotante solo despues de elegir personaje === */

.rpc-widget.rpc-selector-mode {
    position: static !important;
    width: auto !important;
    max-width: 960px !important;
    margin: 32px auto !important;
    z-index: auto !important;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 22px 55px rgba(15, 23, 42, 0.10);
    overflow: hidden;
}

.rpc-widget.rpc-selector-mode .rpc-launcher,
.rpc-widget.rpc-selector-mode .rpc-selector-minimize,
.rpc-widget.rpc-selector-mode .rpc-chat {
    display: none !important;
}

.rpc-widget.rpc-selector-mode .rpc-selector {
    display: block !important;
}

.rpc-widget.rpc-selector-mode .rpc-persona-grid {
    grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)) !important;
}

.rpc-widget.rpc-floating-widget:not(.rpc-collapsed) {
    width: min(520px, calc(100vw - 32px));
}

.rpc-widget.rpc-floating-widget:not(.rpc-collapsed) .rpc-chat {
    display: flex !important;
}

.rpc-widget.rpc-floating-widget:not(.rpc-collapsed) .rpc-selector {
    display: none !important;
}

@media (max-width: 700px) {
    .rpc-widget.rpc-selector-mode {
        margin: 16px auto !important;
        width: calc(100% - 20px) !important;
        border-radius: 22px !important;
        min-height: auto !important;
    }

    .rpc-widget.rpc-floating-widget:not(.rpc-collapsed) {
        left: 10px;
        right: 10px;
        bottom: 10px;
        width: auto;
    }
}

/* RPC PATCH: cabecera de chat mas limpia */
.rpc-chat-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rpc-back {
    display: none !important;
}

.rpc-close-chat {
    white-space: nowrap;
}

.rpc-minimize,
.rpc-selector-minimize {
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0 !important;
    font-size: 22px !important;
    line-height: 1 !important;
    text-align: center;
}

/* RPC PATCH UI: cabecera estetica del chat */
.rpc-chat-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    padding: 8px 14px !important;
}

.rpc-current-persona {
    order: 1 !important;
    flex: 1 1 auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    min-width: 0 !important;
    text-align: left !important;
}

.rpc-current-persona img,
.rpc-current-initial {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
}

.rpc-current-persona > div {
    min-width: 0 !important;
}

.rpc-current-persona strong {
    display: block !important;
    font-size: 14px !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.rpc-current-persona small {
    display: block !important;
    font-size: 12px !important;
    line-height: 1.2 !important;
    opacity: .7 !important;
}

.rpc-chat-actions {
    order: 2 !important;
    margin-left: auto !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex: 0 0 auto !important;
}

.rpc-close-chat,
.rpc-minimize {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 999px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0 !important;
    line-height: 1 !important;
    cursor: pointer !important;
    box-shadow: none !important;
}

.rpc-minimize::before {
    content: "\2212";
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
}

.rpc-close-chat::before {
    content: "\00d7";
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
}

.rpc-close-chat:hover,
.rpc-minimize:hover {
    transform: translateY(-1px);
}

.rpc-back {
    display: none !important;
}

/* RPC PATCH UI V2: cabecera profesional, confirmacion y respuestas rapidas */
.rpc-chat-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    padding: 8px 14px !important;
    min-height: 56px !important;
}

.rpc-current-persona {
    order: 1 !important;
    flex: 1 1 auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    min-width: 0 !important;
    text-align: left !important;
    cursor: pointer !important;
    border-radius: 14px !important;
    padding: 4px 8px 4px 4px !important;
    transition: background .15s ease, transform .15s ease !important;
}

.rpc-current-persona:hover {
    background: rgba(124, 58, 237, .08) !important;
}

.rpc-current-persona::after {
    content: "\2304" !important;
    font-size: 16px !important;
    opacity: .65 !important;
    margin-left: 2px !important;
}

.rpc-current-persona img,
.rpc-current-initial {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
}

.rpc-current-text {
    min-width: 0 !important;
}

.rpc-current-persona strong {
    display: block !important;
    font-size: 14px !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.rpc-current-persona small {
    display: block !important;
    font-size: 12px !important;
    line-height: 1.2 !important;
    opacity: .7 !important;
}

.rpc-chat-actions {
    order: 2 !important;
    margin-left: auto !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex: 0 0 auto !important;
}

.rpc-close-chat,
.rpc-minimize,
.rpc-selector-minimize {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 999px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 22px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    cursor: pointer !important;
    box-shadow: none !important;
    transition: transform .15s ease, background .15s ease !important;
}

.rpc-close-chat {
    font-size: 24px !important;
}

.rpc-close-chat:hover,
.rpc-minimize:hover,
.rpc-selector-minimize:hover {
    transform: translateY(-1px) !important;
}

.rpc-back {
    display: none !important;
}

.rpc-close-confirm {
    position: absolute !important;
    inset: 0 !important;
    z-index: 30 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 24px !important;
    background: rgba(15, 23, 42, .28) !important;
    backdrop-filter: blur(3px) !important;
}

.rpc-close-confirm-box {
    width: min(340px, 100%) !important;
    background: #fff !important;
    border-radius: 22px !important;
    padding: 22px !important;
    box-shadow: 0 20px 60px rgba(15, 23, 42, .20) !important;
    text-align: center !important;
}

.rpc-close-confirm-box strong {
    display: block !important;
    font-size: 17px !important;
    margin-bottom: 8px !important;
}

.rpc-close-confirm-box p {
    margin: 0 0 18px !important;
    font-size: 14px !important;
    opacity: .75 !important;
}

.rpc-close-confirm-actions {
    display: flex !important;
    justify-content: center !important;
    gap: 10px !important;
}

.rpc-confirm-cancel,
.rpc-confirm-close {
    border: 0 !important;
    border-radius: 999px !important;
    padding: 10px 16px !important;
    cursor: pointer !important;
    font-weight: 700 !important;
}

.rpc-quick-replies {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    margin: 10px 0 4px 58px !important;
}

.rpc-quick-reply {
    border: 0 !important;
    border-radius: 999px !important;
    padding: 9px 13px !important;
    font-size: 13px !important;
    cursor: pointer !important;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .08) !important;
    transition: transform .15s ease, box-shadow .15s ease !important;
}

.rpc-quick-reply:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 8px 22px rgba(15, 23, 42, .12) !important;
}

@media (max-width: 520px) {
    .rpc-chat-header {
        padding: 12px 14px !important;
    }

    .rpc-current-persona img,
    .rpc-current-initial {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
    }

    .rpc-quick-replies {
        margin-left: 0 !important;
    }
}

/* Final override: keep only the in-chat AI notice and make message history scrollable. */
.rpc-ai-disclosure {
    display: none !important;
}

.rpc-chat,
.rpc-widget.rpc-floating-widget .rpc-chat,
.rpc-widget.rpc-floating-widget:not(.rpc-collapsed) .rpc-chat {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    min-height: 0 !important;
}

.rpc-chat-header,
.rpc-form,
.rpc-legal-panel,
.rpc-consent-gate {
    flex: 0 0 auto !important;
}

.rpc-messages {
    flex: 1 1 auto !important;
    min-height: 120px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    touch-action: pan-y !important;
}

.rpc-privacy-details-body {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    touch-action: pan-y !important;
}

.rpc-widget.rpc-floating-widget .rpc-messages {
    max-height: none !important;
}

@media (max-width: 700px) {
    .rpc-widget.rpc-floating-widget .rpc-chat {
        height: min(86vh, 680px) !important;
    }
}

/* Final override: keep only the in-chat AI notice and make message history scrollable. */
.rpc-ai-disclosure {
    display: none !important;
}

.rpc-chat,
.rpc-widget.rpc-floating-widget .rpc-chat,
.rpc-widget.rpc-floating-widget:not(.rpc-collapsed) .rpc-chat {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    min-height: 0 !important;
}

.rpc-chat-header,
.rpc-form,
.rpc-legal-panel,
.rpc-consent-gate {
    flex: 0 0 auto !important;
}

.rpc-messages {
    flex: 1 1 auto !important;
    min-height: 120px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    touch-action: pan-y !important;
}

.rpc-widget.rpc-floating-widget .rpc-messages {
    max-height: none !important;
}

@media (max-width: 700px) {
    .rpc-widget.rpc-floating-widget .rpc-chat {
        height: min(86vh, 680px) !important;
    }
}

/* Final chat layout guard: the AI notice lives inside the message history only. */
.rpc-ai-disclosure {
    display: none !important;
}

.rpc-chat,
.rpc-widget.rpc-floating-widget .rpc-chat,
.rpc-widget.rpc-floating-widget:not(.rpc-collapsed) .rpc-chat {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    min-height: 0 !important;
}

.rpc-chat-header,
.rpc-form,
.rpc-legal-panel,
.rpc-consent-gate {
    flex: 0 0 auto !important;
}

.rpc-messages {
    flex: 1 1 auto !important;
    min-height: 120px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    touch-action: pan-y !important;
}

.rpc-widget.rpc-floating-widget .rpc-messages {
    max-height: none !important;
}

@media (max-width: 700px) {
    .rpc-widget.rpc-floating-widget .rpc-chat {
        height: min(86vh, 680px) !important;
    }
}

/* Compact header override */
.rpc-chat-header {
    padding: 8px 12px !important;
    min-height: 56px !important;
    gap: 8px !important;
}

.rpc-current-persona {
    gap: 8px !important;
    padding: 2px 4px 2px 2px !important;
}

.rpc-current-persona img,
.rpc-current-initial,
.rpc-current-persona > span {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
}

.rpc-current-persona strong {
    font-size: 13px !important;
    line-height: 1.1 !important;
}

.rpc-current-persona small {
    font-size: 11px !important;
    line-height: 1.1 !important;
}

.rpc-current-persona::after {
    font-size: 13px !important;
    margin-left: 0 !important;
}

.rpc-chat-actions {
    gap: 6px !important;
}

.rpc-close-chat,
.rpc-minimize,
.rpc-selector-minimize {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    font-size: 18px !important;
}

.rpc-close-chat {
    font-size: 20px !important;
}

@media (max-width: 520px) {
    .rpc-chat-header {
        padding: 8px 10px !important;
        min-height: 52px !important;
    }

    .rpc-current-persona img,
    .rpc-current-initial,
    .rpc-current-persona > span {
        width: 30px !important;
        height: 30px !important;
        min-width: 30px !important;
    }

    .rpc-current-persona strong {
        font-size: 12px !important;
    }

    .rpc-current-persona small {
        font-size: 10px !important;
    }

    .rpc-close-chat,
    .rpc-minimize,
    .rpc-selector-minimize {
        width: 30px !important;
        height: 30px !important;
        min-width: 30px !important;
        font-size: 16px !important;
    }
}

/* RPC PATCH UI V3: corregir iconos duplicados y selector integrado */
.rpc-minimize::before,
.rpc-close-chat::before,
.rpc-selector-minimize::before {
    content: none !important;
    display: none !important;
}

.rpc-chat-header {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    padding: 8px 14px !important;
    min-height: 56px !important;
}

.rpc-current-persona {
    order: 1 !important;
    flex: 1 1 auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    min-width: 0 !important;
    text-align: left !important;
    cursor: pointer !important;
    border-radius: 16px !important;
    padding: 5px 10px 5px 5px !important;
    transition: background .15s ease, transform .15s ease !important;
}

.rpc-current-persona:hover {
    background: rgba(124, 58, 237, .08) !important;
}

.rpc-current-persona::after {
    content: "\2304" !important;
    font-size: 16px !important;
    opacity: .65 !important;
    margin-left: 2px !important;
}

.rpc-current-persona img,
.rpc-current-initial,
.rpc-current-persona > span {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
}

.rpc-current-text {
    min-width: 0 !important;
}

.rpc-current-persona strong {
    display: block !important;
    font-size: 14px !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.rpc-current-persona small {
    display: block !important;
    font-size: 12px !important;
    line-height: 1.2 !important;
    opacity: .7 !important;
}

.rpc-chat-actions {
    order: 2 !important;
    margin-left: auto !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex: 0 0 auto !important;
}

.rpc-close-chat,
.rpc-minimize,
.rpc-selector-minimize {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 999px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 22px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    cursor: pointer !important;
    box-shadow: none !important;
    transition: transform .15s ease, background .15s ease !important;
}

.rpc-close-chat {
    font-size: 24px !important;
}

.rpc-close-chat:hover,
.rpc-minimize:hover,
.rpc-selector-minimize:hover {
    transform: translateY(-1px) !important;
}

.rpc-persona-menu {
    position: absolute !important;
    top: calc(100% - 8px) !important;
    left: 18px !important;
    right: 18px !important;
    z-index: 40 !important;
    background: #fff !important;
    border-radius: 20px !important;
    padding: 8px !important;
    box-shadow: 0 18px 50px rgba(15, 23, 42, .18) !important;
    border: 1px solid rgba(15, 23, 42, .08) !important;
}

.rpc-persona-menu-item {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    border: 0 !important;
    background: transparent !important;
    border-radius: 14px !important;
    padding: 10px !important;
    text-align: left !important;
    cursor: pointer !important;
}

.rpc-persona-menu-item:hover,
.rpc-persona-menu-item.is-active {
    background: rgba(124, 58, 237, .08) !important;
}

.rpc-persona-menu-avatar img,
.rpc-persona-menu-avatar span {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.rpc-persona-menu-text strong {
    display: block !important;
    font-size: 14px !important;
    line-height: 1.2 !important;
}

.rpc-persona-menu-text small {
    display: block !important;
    font-size: 12px !important;
    opacity: .7 !important;
    line-height: 1.2 !important;
}

.rpc-close-confirm {
    position: absolute !important;
    inset: 0 !important;
    z-index: 50 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 24px !important;
    background: rgba(15, 23, 42, .28) !important;
    backdrop-filter: blur(3px) !important;
}

.rpc-close-confirm-box {
    width: min(340px, 100%) !important;
    background: #fff !important;
    border-radius: 22px !important;
    padding: 22px !important;
    box-shadow: 0 20px 60px rgba(15, 23, 42, .20) !important;
    text-align: center !important;
}

.rpc-close-confirm-box strong {
    display: block !important;
    font-size: 17px !important;
    margin-bottom: 8px !important;
}

.rpc-close-confirm-box p {
    margin: 0 0 18px !important;
    font-size: 14px !important;
    opacity: .75 !important;
}

.rpc-close-confirm-actions {
    display: flex !important;
    justify-content: center !important;
    gap: 10px !important;
}

.rpc-confirm-cancel,
.rpc-confirm-close {
    border: 0 !important;
    border-radius: 999px !important;
    padding: 10px 16px !important;
    cursor: pointer !important;
    font-weight: 700 !important;
}

.rpc-quick-replies {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    margin: 10px 0 4px 58px !important;
}

.rpc-quick-reply {
    border: 0 !important;
    border-radius: 999px !important;
    padding: 9px 13px !important;
    font-size: 13px !important;
    cursor: pointer !important;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .08) !important;
    transition: transform .15s ease, box-shadow .15s ease !important;
}

.rpc-quick-reply:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 8px 22px rgba(15, 23, 42, .12) !important;
}

@media (max-width: 520px) {
    .rpc-chat-header {
        padding: 12px 14px !important;
    }

    .rpc-current-persona img,
    .rpc-current-initial,
    .rpc-current-persona > span {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
    }

    .rpc-persona-menu {
        left: 12px !important;
        right: 12px !important;
    }

    .rpc-quick-replies {
        margin-left: 0 !important;
    }
}

/* Final override: keep only the in-chat AI notice and make message history scrollable. */
.rpc-ai-disclosure {
    display: none !important;
}

.rpc-chat,
.rpc-widget.rpc-floating-widget .rpc-chat,
.rpc-widget.rpc-floating-widget:not(.rpc-collapsed) .rpc-chat {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    min-height: 0 !important;
}

.rpc-chat-header,
.rpc-form,
.rpc-legal-panel,
.rpc-consent-gate {
    flex: 0 0 auto !important;
}

.rpc-messages {
    flex: 1 1 auto !important;
    min-height: 120px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    touch-action: pan-y !important;
}

.rpc-widget.rpc-floating-widget .rpc-messages {
    max-height: none !important;
}

@media (max-width: 700px) {
    .rpc-widget.rpc-floating-widget .rpc-chat {
        height: min(86vh, 680px) !important;
    }
}

/* Compact legal notice: keep the full policy outside the widget. */
.rpc-chat.rpc-consent-required .rpc-messages {
    min-height: 0 !important;
}

.rpc-ai-start-notice,
.rpc-consent-policy {
    margin: 0;
    line-height: 1.45;
}

.rpc-consent-gate-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
}

.rpc-consent-policy {
    font-size: 12px;
    color: var(--rpc-text-soft);
}

.rpc-consent-policy a,
.rpc-privacy-actions a {
    color: var(--rpc-brand-strong);
    font-weight: 750;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.rpc-legal-panel.rpc-legal-panel-compact {
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 9px 14px;
    overflow: visible !important;
}

.rpc-legal-panel-compact .rpc-privacy-details summary {
    padding: 0;
    border-bottom: 0;
    background: transparent;
}

.rpc-legal-panel-compact .rpc-privacy-details-body {
    max-height: min(180px, 24vh);
    padding: 10px 0 0;
    background: transparent;
}

.rpc-privacy-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin: 0 0 10px;
}

.rpc-privacy-actions .rpc-consent-withdraw {
    margin-left: 0;
}

/* El widget flotante de usuarios conectados puede abrirse sin personaje elegido. */
.rpc-widget.rpc-floating-widget:not(.rpc-collapsed):not(.rpc-has-persona) .rpc-selector {
    display: block !important;
}

.rpc-widget.rpc-floating-widget:not(.rpc-collapsed):not(.rpc-has-persona) .rpc-chat {
    display: none !important;
}

.rpc-widget.rpc-floating-widget:not(.rpc-collapsed).rpc-has-persona .rpc-selector {
    display: none !important;
}

.rpc-widget.rpc-floating-widget:not(.rpc-collapsed).rpc-has-persona .rpc-chat {
    display: flex !important;
}
