/* Character Chat and its profile CTA. Isolated from existing Character Show CSS. */
.rv-character-heading__actions { display:flex; flex-wrap:wrap; align-items:center; justify-content:flex-end; gap:.65rem; }
.rv-character .rv-chat-entry { background:#fff; border:1px solid #fff; color:#a60a15 !important; text-decoration:none; }
.rv-character .rv-chat-entry i, .rv-character .rv-chat-entry span { color:#a60a15 !important; }
.rv-character .rv-chat-entry:hover, .rv-character .rv-chat-entry:focus-visible { background:#ffe6eb; border-color:#ffe6eb; color:#a60a15 !important; }
.rv-character .rv-chat-entry:hover i, .rv-character .rv-chat-entry:hover span { color:#a60a15 !important; }
.rv-character .rv-character-heading__actions .rv-character-btn--quiet { color:#fff !important; background:transparent; border:1px solid rgba(255,255,255,.75); }
.rv-character .rv-character-heading__actions .rv-character-btn--quiet :is(span,i) { color:#fff !important; }
.rv-character .rv-character-heading__actions .rv-character-btn--quiet:hover { background:rgba(255,255,255,.13); border-color:#fff; color:#fff !important; }
.rv-character .rv-character-heading__actions .rv-character-btn--quiet:hover :is(span,i) { color:#fff !important; }
.rv-chat { --rv-red:#ce2842; --rv-red-dark:#a60a15; --rv-border:#ece5e7; color:#353039; padding-top:110px; padding-bottom:68px; }
.rv-chat-breadcrumb { display:flex; align-items:center; gap:.45rem; flex-wrap:wrap; font-size:.81rem; margin-bottom:18px; color:#79717a; }
.rv-chat-breadcrumb a { text-decoration:none; color:#9e2438; }
.rv-chat-breadcrumb a:hover { text-decoration:underline; }
.rv-chat-heading { background:#ce2842; color:white; padding:26px 30px; border-radius:15px; display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:18px; margin-bottom:22px; }
.rv-chat-heading__identity { display:flex; align-items:center; gap:19px; min-width:0; }
.rv-chat-avatar { width:76px; height:76px; border-radius:16px; object-fit:cover; border:3px solid rgba(255,255,255,.35); flex-shrink:0; }
.rv-chat-eyebrow { letter-spacing:.1em; font-size:.68rem; font-weight:700; color:#ffe2e7; }
.rv-chat-heading h1 { font-size:clamp(1.18rem,2vw,1.7rem); line-height:1.2; margin:.35rem 0; color:white; overflow-wrap:anywhere; }
.rv-chat-heading p { font-size:.83rem; color:#ffe1e6; margin:0; }
.rv-chat-back { border:1px solid #ffd5dc; color:#fff !important; border-radius:9px; padding:.65rem 1rem; text-decoration:none; white-space:nowrap; font-size:.83rem; }
.rv-chat-back:hover, .rv-chat-back:focus-visible { background:white; color:var(--rv-red-dark) !important; }
.rv-chat-panel { border:1px solid var(--rv-border); border-radius:15px; background:white; overflow:hidden; box-shadow:0 4px 22px rgba(48,24,28,.035); }
.rv-chat-notice { display:flex; align-items:start; gap:.65rem; background:#fff6f7; color:#71414b; font-size:.82rem; padding:14px 20px; border-bottom:1px solid #f6e0e5; }
.rv-chat-notice i { font-size:1.1rem; color:var(--rv-red); flex:0 0 auto; }
.rv-chat-transcript { display:flex; flex-direction:column; gap:16px; min-height:270px; max-height:min(62vh,630px); overflow:auto; padding:24px; scrollbar-width:thin; overscroll-behavior:contain; }
.rv-chat-empty { color:#817b82; font-size:.89rem; text-align:center; margin:auto; }
.rv-chat-message { max-width:min(84%,720px); align-self:flex-start; }
.rv-chat-message.is-user { align-self:flex-end; }
.rv-chat-message__sender { font-size:.72rem; color:#8c747c; font-weight:700; display:block; margin-bottom:.4rem; }
.rv-chat-message.is-user .rv-chat-message__sender { text-align:right; }
.rv-chat-message__text { background:#f7f6f7; border:1px solid #f1edef; padding:14px 17px; border-radius:13px 13px 13px 4px; white-space:pre-wrap; overflow-wrap:anywhere; margin:0; font-size:.91rem; line-height:1.65; }
.rv-chat-message.is-user .rv-chat-message__text { background:#fff0f3; border-color:#f5d8df; border-radius:13px 13px 4px 13px; }
.rv-chat-message__error { color:#b22036; font-weight:600; font-size:.79rem; display:block; margin-top:.35rem; }
.rv-chat-wait { display:flex; align-items:center; gap:.7rem; margin:0 24px 17px; padding:11px 13px; border-radius:10px; color:#864051; background:#fff3f5; font-size:.82rem; }
.rv-chat-wait[hidden], .rv-chat-error[hidden] { display:none !important; }
.rv-chat-wait__dots { display:flex; gap:4px; }
.rv-chat-wait__dots span { width:5px; height:5px; border-radius:50%; background:#ce2842; animation:rv-chat-dot 1.1s infinite ease-in-out alternate; }
.rv-chat-wait__dots span:nth-child(2) { animation-delay:.25s; }
.rv-chat-wait__dots span:nth-child(3) { animation-delay:.5s; }
@keyframes rv-chat-dot { to { opacity:.25; transform:translateY(-3px); } }
.rv-chat-error { color:#b22036; padding:9px 24px; font-size:.83rem; margin:0; }
.rv-chat-composer { border-top:1px solid var(--rv-border); padding:17px 20px 14px; }
.rv-chat-composer label { display:block; font-size:.82rem; font-weight:700; margin-bottom:.4rem; color:#5f4c54; }
.rv-chat-composer__row { display:flex; align-items:stretch; gap:11px; }
.rv-chat-composer textarea { width:100%; flex:1; min-width:0; resize:vertical; min-height:85px; max-height:220px; padding:12px 14px; color:#333; border:1px solid #dcd7da; border-radius:10px; outline:none; line-height:1.55; }
.rv-chat-composer textarea:focus { border-color:var(--rv-red); box-shadow:0 0 0 3px rgba(206,40,66,.10); }
.rv-chat-composer textarea:disabled { background:#f8f7f8; }
.rv-chat-send, .rv-chat-button { display:inline-flex; justify-content:center; align-items:center; gap:.45rem; padding:0 20px; background:var(--rv-red); color:white !important; border:1px solid var(--rv-red); border-radius:10px; font-weight:700; text-decoration:none; }
.rv-chat-send:hover:not(:disabled), .rv-chat-button:hover { background:var(--rv-red-dark); border-color:var(--rv-red-dark); color:white !important; }
.rv-chat-send:disabled { opacity:.48; cursor:wait; }
.rv-chat-composer__hint { display:flex; justify-content:space-between; flex-wrap:wrap; gap:8px; color:#90888d; font-size:.72rem; margin-top:.5rem; }
.rv-chat-gate { background:white; border:1px solid var(--rv-border); text-align:center; border-radius:14px; padding:42px 25px; }
.rv-chat-gate>i { font-size:2.25rem; color:var(--rv-red); }
.rv-chat-gate h2 { margin:12px 0; font-size:1.2rem; }
.rv-chat-gate p { color:#777077; font-size:.91rem; max-width:600px; margin:0 auto 14px; }
.rv-chat-gate .rv-chat-gate__details { color:#9e2438; }
.rv-chat-gate .rv-chat-button { margin-top:.6rem; padding:12px 18px; }
@media(max-width:767.98px) { .rv-chat { padding-top:104px; } .rv-chat-heading { padding:20px; } .rv-chat-avatar { width:60px; height:60px; border-radius:12px; } .rv-chat-transcript { padding:16px; max-height:58vh; } .rv-chat-message { max-width:94%; } .rv-chat-composer { padding:14px; } .rv-character-heading__actions { justify-content:flex-start; width:100%; } }
@media(max-width:575.98px) { .rv-character .rv-character-heading { flex-wrap:wrap; } }
@media(max-width:420px) { .rv-chat-heading__identity { align-items:flex-start; gap:12px; } .rv-chat-back { width:100%; text-align:center; } .rv-chat-composer__row { flex-direction:column; } .rv-chat-send { padding:11px 14px; } .rv-chat-message__text { font-size:.87rem; padding:12px; } .rv-chat-composer__hint>span:first-child { display:none; } }
@media(prefers-reduced-motion:reduce) { .rv-chat-wait__dots span { animation:none; } }

/* Secondary language label keeps the informational hierarchy below the title. */
.rv-chat-heading .rv-chat-language { margin-top:.2rem; font-size:.76rem; color:#fff2f4; }

/* Conversation reset: reuse the page's existing red / pale-pink palette. */
.rv-chat-heading__actions { display:flex; flex-wrap:wrap; align-items:center; gap:.65rem; }
.rv-chat-heading__actions form { margin:0; }
.rv-chat-heading__actions form[hidden] { display:none; }
.rv-chat-clear { width:42px; height:42px; display:inline-grid; place-items:center; cursor:pointer;
    padding:0; border:1px solid rgba(255,255,255,.85); background:transparent;
    border-radius:9px; color:#fff; font-size:1.24rem; }
.rv-chat-clear:hover, .rv-chat-clear:focus-visible { background:#fff; color:var(--rv-red-dark); }
.rv-chat-clear:disabled { opacity:.55; cursor:wait; }
.rv-chat-confirm { box-sizing:border-box; width:calc(100% - 30px); max-width:440px;
    padding:24px; border:1px solid #f0d9de; border-radius:15px;
    background:white; color:#353039; box-shadow:0 18px 50px rgba(30,18,24,.22); }
.rv-chat-confirm::backdrop { background:rgba(22,18,22,.52); }
.rv-chat-confirm h2 { font-size:1.2rem; color:#353039; margin:0 0 10px; }
.rv-chat-confirm p { font-size:.87rem; line-height:1.6; color:#6d626b; margin:0 0 20px; }
.rv-chat-confirm__actions { display:flex; gap:10px; justify-content:flex-end; flex-wrap:wrap; }
.rv-chat-confirm__actions button { border-radius:9px; padding:10px 14px; font-size:.82rem;
    font-weight:700; cursor:pointer; }
.rv-chat-confirm__cancel { border:1px solid #e4dadd; background:#fff; color:#5b4d55; }
.rv-chat-confirm__delete { border:1px solid var(--rv-red); background:var(--rv-red); color:#fff; }
.rv-chat-confirm__delete:hover { background:var(--rv-red-dark); }
.rv-chat-confirm__actions button:disabled { opacity:.55; cursor:wait; }
@media(max-width:420px) { .rv-chat-heading__actions { width:100%; justify-content:flex-end; }
  .rv-chat-heading__actions .rv-chat-back { width:auto; flex:1; }
  .rv-chat-confirm { padding:18px; }
  .rv-chat-confirm__actions button { flex:1; }
}

/* Floating character identity: keep the conversation partner visible while scrolling.
   --rv-chat-floating-top is read from the existing fixed site navbar by the chat JS. */
.rv-chat-heading {
    position: sticky;
    top: var(--rv-chat-floating-top, 88px);
    z-index: 99; /* The original site navbar is z-index: 101. */
    box-shadow: 0 8px 22px rgba(69, 19, 30, .16);
}
.rv-chat-heading__details { min-width: 0; }
.rv-chat-back { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; }
.rv-chat-back__label { white-space: nowrap; }

@media (max-width: 767.98px) {
    /* Compact, one-row messaging header on mobile. No oversized blank row. */
    .rv-chat-heading {
        display: flex;
        align-items: center;
        flex-wrap: nowrap;
        min-height: 64px;
        padding: 9px 11px;
        gap: 8px;
        margin-bottom: 12px;
        border-radius: 13px;
    }
    .rv-chat-heading__identity {
        flex: 1 1 auto;
        min-width: 0;
        gap: 9px;
        align-items: center;
    }
    .rv-chat-avatar {
        width: 44px;
        height: 44px;
        border-width: 2px;
        border-radius: 50%;
    }
    .rv-chat-heading__details { min-width: 0; flex: 1 1 auto; }
    .rv-chat-heading h1 {
        display: block;
        margin: 0 0 3px;
        font-size: clamp(.90rem, 4vw, 1.04rem);
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        overflow-wrap: normal;
    }
    .rv-chat-heading .rv-chat-language {
        margin: 0;
        font-size: .68rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .rv-chat-heading__actions {
        flex: 0 0 auto;
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: flex-end;
        width: auto;
        gap: 6px;
    }
    .rv-chat-heading__actions form { margin: 0; }
    .rv-chat-heading__actions .rv-chat-back,
    .rv-chat-heading__actions .rv-chat-clear {
        box-sizing: border-box;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 36px;
        width: 36px;
        height: 36px;
        padding: 0;
        border-radius: 9px;
        font-size: 1.12rem;
    }
    /* Keep the back link text accessible to assistive technology. */
    .rv-chat-back__label {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
}

@media (max-width: 420px) {
    /* Override the older 420px rules which expanded the Back button. */
    .rv-chat-heading__identity { align-items: center; }
    .rv-chat-heading__actions { width: auto; flex-wrap: nowrap; justify-content: flex-end; }
    .rv-chat-heading__actions .rv-chat-back { flex: 0 0 36px; width: 36px; text-align: center; }
}

/* v12: Keep character identity on screen while scrolling on phones.
   The message transcript scrolls independently, so viewport-fixed works here
   more reliably than sticky. Desktop retains the v11 sticky header. */
@media (max-width: 767.98px) {
    .rv-chat {
        /* Make room below RPverse's existing fixed navbar and chat identity. */
        padding-top: calc(var(--rv-chat-floating-top, 88px) + 76px);
    }
    .rv-chat .rv-chat-heading {
        position: fixed;
        top: var(--rv-chat-floating-top, 88px);
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: calc(100vw - 32px);
        max-width: 508px;
        margin: 0;
        z-index: 100; /* The existing site navbar is z-index: 101. */
        box-sizing: border-box;
        box-shadow: 0 8px 22px rgba(69, 19, 30, .20);
    }
}
@media (max-width: 575.98px) {
    /* Below Bootstrap's first container breakpoint, use full inner width. */
    .rv-chat .rv-chat-heading { max-width: none; }
}
