.ypwi-chat-launcher{
    position:fixed;
    right:16px;
    bottom:82px;
    z-index:1001;
    width:60px;
    height:60px;
    border:0;
    border-radius:50%;
    padding:0;
    overflow:hidden;
    color:#fff;
    background:linear-gradient(135deg,var(--chat-primary,#7c3aed),var(--chat-secondary,#5b21b6));
    box-shadow:0 10px 28px rgba(91,33,182,.35);
    box-shadow:0 10px 28px color-mix(in srgb,var(--chat-primary,#7c3aed) 38%,transparent);
    font-size:29px;
    cursor:pointer;
}
.ypwi-chat-launcher:focus-visible,
.ypwi-chat-close:focus-visible,
.ypwi-chat-head-action:focus-visible,
.ypwi-chat-mini-action:focus-visible,
.ypwi-chat-suggestion:focus-visible,
.ypwi-chat-send:focus-visible{
    outline:3px solid rgba(124,58,237,.38);
    outline:3px solid color-mix(in srgb,var(--chat-primary,#7c3aed) 38%,transparent);
    outline-offset:3px;
}
.ypwi-chat-launcher img{
    display:block;
    width:100%;
    height:100%;
    object-fit:contain;
    border-radius:50%;
}
.ypwi-chat-unread{
    position:absolute;
    top:-4px;
    right:-3px;
    display:grid;
    place-items:center;
    min-width:19px;
    height:19px;
    padding:0 4px;
    border:2px solid #fff;
    border-radius:999px;
    background:#ef4444;
    color:#fff;
    font-size:9px;
    font-weight:800;
    line-height:1;
}
.ypwi-chat-unread[hidden]{display:none!important;}
.ypwi-chat-launcher.has-new-message{animation:ypwiLauncherNotice .55s ease;}
@keyframes ypwiLauncherNotice{
    0%,100%{transform:scale(1);}
    45%{transform:scale(1.12) rotate(-4deg);}
}
.ypwi-chat-label{
    position:fixed;
    right:84px;
    bottom:94px;
    z-index:1000;
    padding:8px 11px;
    border-radius:999px;
    background:#fff;
    color:var(--chat-primary,#7c3aed);
    box-shadow:0 6px 18px rgba(15,23,42,.18);
    font-size:13px;
    font-weight:700;
    white-space:nowrap;
}
.ypwi-chat-panel{
    position:fixed;
    right:16px;
    bottom:152px;
    z-index:1002;
    display:none;
    flex-direction:column;
    width:min(380px,calc(100vw - 24px));
    height:min(570px,calc(100dvh - 175px));
    overflow:hidden;
    border:2px solid var(--chat-primary,#7c3aed);
    border-radius:18px;
    background:#fff;
    box-shadow:0 18px 50px rgba(15,23,42,.25);
}
.ypwi-chat-panel.open{display:flex;}
.ypwi-chat-header{
    display:flex;
    align-items:center;
    gap:10px;
    padding:13px 14px;
    color:#fff;
    /* Judul dibuat lebih terang dan tegas daripada isi percakapan. */
    background:linear-gradient(135deg,
        color-mix(in srgb,var(--chat-primary,#7c3aed) 78%,white),
        var(--chat-primary,#7c3aed) 58%,
        var(--chat-secondary,#5b21b6));
}
.ypwi-chat-avatar{
    display:grid;
    place-items:center;
    width:40px;
    height:40px;
    flex:none;
    border-radius:50%;
    background:rgba(255,255,255,.2);
    font-size:22px;
}
.ypwi-chat-avatar img{
    display:block;
    width:38px;
    height:38px;
    object-fit:contain;
}
.ypwi-chat-title{min-width:0;flex:1;}
.ypwi-chat-title strong{display:block;font-size:15px;}
.ypwi-chat-title small{display:flex;align-items:center;gap:5px;margin-top:2px;opacity:.92;font-size:11px;}
.ypwi-chat-online-dot{
    width:7px;
    height:7px;
    flex:none;
    border-radius:50%;
    background:#86efac;
    box-shadow:0 0 0 3px rgba(134,239,172,.18);
}
.ypwi-chat-online-dot.offline{background:#fbbf24;box-shadow:0 0 0 3px rgba(251,191,36,.18);}
.ypwi-chat-head-action,
.ypwi-chat-close{
    width:36px;
    height:36px;
    border:0;
    border-radius:50%;
    color:#fff;
    background:rgba(255,255,255,.14);
    font-size:24px;
    cursor:pointer;
}
.ypwi-chat-head-action{
    font-size:21px;
    line-height:1;
    transition:transform .2s ease,background .2s ease;
}
.ypwi-chat-head-action:hover{transform:rotate(-35deg);background:rgba(255,255,255,.24);}
.ypwi-chat-head-action:disabled{opacity:.5;cursor:wait;}
.ypwi-chat-messages{
    flex:1;
    overflow-y:auto;
    padding:14px;
    /* Area isi sengaja netral agar fokus warna hanya berada pada header. */
    background:linear-gradient(180deg,#f8fafc 0%,#ffffff 58%,#f6f8fb 100%);
    overscroll-behavior:contain;
}
.ypwi-chat-day-separator{
    display:flex;
    align-items:center;
    gap:8px;
    margin:2px 0 12px;
    color:#8793a3;
    font-size:9px;
    text-align:center;
}
.ypwi-chat-day-separator::before,
.ypwi-chat-day-separator::after{
    content:"";
    height:1px;
    flex:1;
    background:#e7ebf0;
}
.ypwi-chat-message{
    max-width:86%;
    margin:0 0 10px;
    padding:10px 12px;
    border-radius:14px;
    font-size:14px;
    line-height:1.45;
    white-space:pre-wrap;
    overflow-wrap:anywhere;
    opacity:0;
    transform:translateY(5px) scale(.99);
    transition:opacity .2s ease,transform .2s ease;
}
.ypwi-chat-message.visible{opacity:1;transform:none;}
.ypwi-chat-text{white-space:pre-wrap;overflow-wrap:anywhere;}
.ypwi-chat-text.collapsed{
    position:relative;
    max-height:145px;
    overflow:hidden;
    -webkit-mask-image:linear-gradient(to bottom,#000 72%,transparent 100%);
    mask-image:linear-gradient(to bottom,#000 72%,transparent 100%);
}
.ypwi-chat-message.bot{
    margin-right:auto;
    border-bottom-left-radius:4px;
    background:#fff;
    border:1px solid #e7ebf0;
    color:#1f2937;
    box-shadow:0 2px 8px rgba(15,23,42,.07);
}
.ypwi-chat-message.user{
    margin-left:auto;
    border-bottom-right-radius:4px;
    /* Gelembung pengguna memakai versi pastel, bukan warna kuat milik header. */
    background:#e7eef8;
    background:color-mix(in srgb,var(--chat-primary,#7c3aed) 13%,white);
    color:#1e293b;
    border:1px solid #d8e2ef;
    border-color:color-mix(in srgb,var(--chat-primary,#7c3aed) 22%,white);
    box-shadow:0 2px 7px rgba(15,23,42,.06);
}
.ypwi-chat-message.status{color:#64748b;font-style:italic;}
.ypwi-chat-meta{
    display:flex;
    align-items:center;
    justify-content:space-between;
    flex-wrap:wrap;
    gap:5px 9px;
    margin-top:8px;
    padding-top:6px;
    border-top:1px solid rgba(148,163,184,.18);
    color:#7c8798;
    font-size:9px;
    line-height:1.2;
    white-space:normal;
}
.ypwi-chat-message.user .ypwi-chat-meta{justify-content:flex-end;}
.ypwi-chat-message-actions{display:flex;flex-wrap:wrap;gap:3px;}
.ypwi-chat-mini-action{
    border:0;
    border-radius:999px;
    padding:3px 6px;
    background:#f1f5f9;
    color:#526071;
    font:inherit;
    font-size:9px;
    cursor:pointer;
}
.ypwi-chat-mini-action:hover{background:#e2e8f0;color:#1e293b;}
.ypwi-chat-mini-action.done{color:#15803d;background:#ecfdf3;}
.ypwi-chat-typing{
    display:flex;
    align-items:center;
    gap:8px;
    min-width:170px;
    font-style:normal!important;
}
.ypwi-chat-typing-dots{display:inline-flex;align-items:center;gap:3px;}
.ypwi-chat-typing-dots i{
    width:6px;
    height:6px;
    border-radius:50%;
    background:var(--chat-primary,#7c3aed);
    animation:ypwiTyping 1s infinite ease-in-out;
}
.ypwi-chat-typing-dots i:nth-child(2){animation-delay:.15s;}
.ypwi-chat-typing-dots i:nth-child(3){animation-delay:.3s;}
.ypwi-chat-typing-text{font-size:11px;color:#64748b;}
@keyframes ypwiTyping{
    0%,70%,100%{transform:translateY(0);opacity:.35;}
    35%{transform:translateY(-4px);opacity:1;}
}
.ypwi-chat-continue{
    display:inline-block;
    margin-top:10px;
    padding:9px 12px;
    border-radius:10px;
    background:var(--chat-primary,#7c3aed);
    color:#fff;
    font-weight:700;
    text-decoration:none;
}
.ypwi-chat-continue:hover,
.ypwi-chat-continue:focus{filter:brightness(.92);}
.ypwi-chat-suggestions{
    display:flex;
    gap:7px;
    overflow-x:auto;
    padding:8px 10px;
    border-top:1px solid #edf0f4;
    background:#fbfcfe;
    scrollbar-width:thin;
}
.ypwi-chat-suggestions:empty{display:none;}
.ypwi-chat-suggestion{
    flex:none;
    max-width:210px;
    border:1px solid #dbe3ee;
    border:1px solid color-mix(in srgb,var(--chat-primary,#7c3aed) 24%,#dbe3ee);
    border-radius:999px;
    padding:7px 10px;
    background:#fff;
    color:#334155;
    font-size:10px;
    line-height:1.2;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    cursor:pointer;
    transition:background .16s ease,color .16s ease,transform .16s ease;
}
.ypwi-chat-suggestion:hover{
    background:color-mix(in srgb,var(--chat-primary,#7c3aed) 9%,white);
    color:var(--chat-primary,#7c3aed);
    transform:translateY(-1px);
}
.ypwi-chat-form{
    display:flex;
    gap:8px;
    padding:10px;
    border-top:1px solid #e5e7eb;
    background:#fff;
}
.ypwi-chat-mic{
    width:42px;
    flex:none;
    border:1px solid #d9e0e8;
    border-radius:12px;
    background:#f8fafc;
    color:#475569;
    font-size:16px;
    cursor:pointer;
}
.ypwi-chat-mic[hidden]{display:none!important;}
.ypwi-chat-mic:hover{background:#eef2f7;}
.ypwi-chat-mic.listening{
    border-color:#ef4444;
    background:#fef2f2;
    color:#dc2626;
    animation:ypwiMicPulse 1.1s infinite;
}
@keyframes ypwiMicPulse{
    0%,100%{box-shadow:0 0 0 0 rgba(239,68,68,.25);}
    50%{box-shadow:0 0 0 6px rgba(239,68,68,0);}
}
.ypwi-chat-input{
    min-width:0;
    flex:1;
    padding:11px 12px;
    border:1px solid #cbd5e1;
    border-radius:12px;
    font:inherit;
    font-size:14px;
}
.ypwi-chat-input:focus{border-color:var(--chat-primary,#7c3aed);outline:2px solid rgba(124,58,237,.18);outline:2px solid color-mix(in srgb,var(--chat-primary,#7c3aed) 18%,transparent);}
.ypwi-chat-send{
    min-width:68px;
    border:0;
    border-radius:12px;
    background:var(--chat-primary,#7c3aed);
    color:#fff;
    font-weight:700;
    cursor:pointer;
}
.ypwi-chat-send:disabled{opacity:.58;cursor:wait;}
.ypwi-chat-footer-note{
    display:flex;
    justify-content:space-between;
    gap:10px;
    margin:0;
    padding:0 12px 9px;
    background:#fff;
    color:#64748b;
    font-size:9px;
}
.ypwi-chat-footer-note span:first-child{
    min-width:0;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}
#ypwiChatCounter{flex:none;font-variant-numeric:tabular-nums;}
#ypwiChatCounter.near-limit{color:#b45309;font-weight:700;}
@media(max-width:360px){
    .ypwi-chat-message{max-width:91%;}
    .ypwi-chat-mini-action{padding:3px 5px;}
    .ypwi-chat-title strong{font-size:13px;}
    .ypwi-chat-head-action,.ypwi-chat-close{width:32px;height:32px;}
}
@media(max-width:520px){
    .ypwi-chat-label{display:none;}
    .ypwi-chat-panel{
        right:12px;
        bottom:82px;
        width:calc(100vw - 24px);
        height:50vh;
        height:50dvh;
        max-height:620px;
        border-radius:18px;
    }
    .ypwi-chat-launcher{right:14px;bottom:80px;}
}
@media(prefers-reduced-motion:reduce){
    *{scroll-behavior:auto!important;}
    .ypwi-chat-message{transition:none;opacity:1;transform:none;}
    .ypwi-chat-typing-dots i{animation:none;}
    .ypwi-chat-launcher.has-new-message,.ypwi-chat-mic.listening{animation:none;}
}
