/* assets/style/chat.css */
.uiBackdrop{
    position: fixed;
    inset: 0;
    z-index: var(--z-chatOverlay);
    background: radial-gradient(1200px 800px at 50% 0%, rgba(0,0,0,.25), rgba(0,0,0,.55));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
}
.uiBackdrop.show{
    opacity: 1;
    pointer-events: auto;
}

.chatFab{
    width: 56px;
    height: 56px;
    border: 1px solid var(--gold);
    border-radius: 18px;
    background: var(--gold);
    color: var(--black);
    font-size: 22px;
    display: grid;
    place-items: center;
    box-shadow: 0 14px 40px rgba(0,0,0,.28);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: pointer;
}
.chatFab:active{ transform: translateY(1px); }

.chatOverlay{
    display:none;
}

body.chat-open::after{
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(11,15,25,.38);
    backdrop-filter: blur(4px);
    z-index: var(--z-chatOverlay);
}

.chatSheet{
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;

    z-index: var(--z-chat);

    color: var(--text-strong);
    background: var(--sheet);

    border-top-left-radius: 22px;
    border-top-right-radius: 22px;
    border: 1px solid var(--border-soft);
    border-bottom: 0;

    box-shadow: var(--shadowUp);

    transform: translateY(110%);
    transition: transform .22s ease;

    height: min(70vh, 560px);
    display: flex;
    flex-direction: column;

    padding-bottom: env(safe-area-inset-bottom);
    will-change: transform;

    pointer-events: auto;
}
.chatSheet.open{ transform: translateY(0); }
.chatSheet.dragging{ transition: none; }

.chatTop{
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;

    padding: 14px 14px 10px;
    border-bottom: 1px solid var(--border-soft);
}
.chatTop::before{
    content:"";
    position:absolute;
    left: 50%;
    top: 8px;
    transform: translateX(-50%);
    width: 44px;
    height: 5px;
    border-radius: 999px;
    background: rgba(2,6,23,.18);
}

.chatClose{
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: rgba(255,255,255,.75);
    color: var(--text-strong);
    font-size: 18px;
    cursor: pointer;
}
.chatClose:active{ transform: translateY(1px); }

.chatTitle{
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    min-width: 0;
}
.chatTitleMain{
    font-weight: 950;
    letter-spacing: .2px;
    color: var(--text-strong);
}
.chatTitleSub{
    display:flex;
    align-items:center;
    gap:8px;
    font-size: 12px;
    margin-top: 2px;
    color: var(--text-muted);
}
.chatTitleSub::before{
    content:"";
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: rgba(2,6,23,.22);
    box-shadow: 0 0 0 4px rgba(2,6,23,.06);
}
.chatSheet.online .chatTitleSub::before{
    background: rgba(46,204,113,.95);
    box-shadow: 0 0 0 4px rgba(46,204,113,.12);
}
.chatSheet.offline .chatTitleSub::before{
    background: rgba(255,77,77,.95);
    box-shadow: 0 0 0 4px rgba(255,77,77,.12);
}

.chatMsgs{
    flex: 1;
    overflow: auto;
    padding: 12px 12px 10px;

    display: flex;
    flex-direction: column;
    gap: 10px;

    scroll-behavior: smooth;
}

.chatMsgRow{
    display:flex;
    flex-direction: column;
    max-width: 78%;
}
.chatMsgRow.me{ align-self: flex-end; align-items: flex-end; }
.chatMsgRow.them{ align-self: flex-start; align-items: flex-start; }

.chatBubble{
    padding: 10px 12px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.25;
    word-break: break-word;
    white-space: pre-wrap;
    border: 1px solid rgba(2,6,23,.10);
}

.chatBubble.me{
    background: var(--gold, #F9D515);
    color: #111;
    border-bottom-right-radius: 7px;
    border-color: rgba(0,0,0,.08);
}
.chatBubble.them{
    background: rgba(2,6,23,.06);
    color: var(--text-strong);
    border-bottom-left-radius: 7px;
}

.chatMeta{
    font-size: 11px;
    margin-top: 4px;
    color: var(--text-muted);
}

.chatComposer{
    display: flex;
    align-items: center;
    gap: 10px;

    padding: 10px 12px 12px;
    border-top: 1px solid var(--border-soft);
    background: var(--sheet);

    pointer-events: auto;
}

.chatIconBtn{
    width: 42px;
    height: 42px;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: rgba(255,255,255,.75);
    color: var(--text-strong);
    font-size: 18px;
    cursor: pointer;

    pointer-events: auto;
}
.chatIconBtn:active{ transform: translateY(1px); }

.chatInput{
    flex: 1;
    height: 42px;
    border-radius: 14px;
    border: 1px solid var(--border-soft);
    background: rgba(255,255,255,.75);
    color: var(--text-strong);
    padding: 0 12px;
    outline: none;

    pointer-events: auto;
}
.chatInput::placeholder{ color: rgba(2,6,23,.42); }
.chatInput:focus{
    border-color: rgba(249,213,21,.55);
    box-shadow: 0 0 0 3px rgba(249,213,21,.10);
}

.chatSend{
    height: 42px;
    padding: 0 14px;
    border: 0;
    border-radius: 14px;
    background: var(--color-brand);
    color: #0B0F19;
    font-weight: 950;
    cursor: pointer;

    pointer-events: auto;
}
.chatSend:active{ transform: translateY(1px); }

.chatEmojiPanel{
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: calc(env(safe-area-inset-bottom) + 64px);
    z-index: calc(var(--z-chat) + 1);

    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;

    padding: 10px 12px 12px;
    border-radius: 16px;
    border: 1px solid var(--border-soft);
    background: rgba(255,255,255,.92);
    box-shadow: 0 16px 50px rgba(0,0,0,.16);
}
.chatEmojiPanel .emo{
    height: 38px;
    border-radius: 12px;
    border: 1px solid var(--border-soft);
    background: rgba(255,255,255,.75);
    color: var(--text-strong);
    font-size: 18px;
    cursor: pointer;
}
.chatEmojiPanel .emo:active{ transform: translateY(1px); }

@media (min-width: 1024px){
    .chatSheet{
        left: 50%;
        transform: translate(-50%, 110%);
        width: min(560px, calc(100% - 24px));
        border-radius: 22px;
        bottom: 12px;
        border-bottom: 1px solid var(--border-soft);
    }
    .chatSheet.open{
        transform: translate(-50%, 0);
    }
}