#tsacChatToggle {
    position: fixed; right: 20px; bottom: 20px; width: 56px; height: 56px;
    border-radius: 50%; background: #6366f1; color: #fff; border: none;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .25); font-size: 1.35rem; z-index: 1050;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
}
#tsacChatToggle:hover { background: #4f46e5; }
.tsac-chat-badge {
    position: absolute; top: -2px; right: -2px; width: 14px; height: 14px;
    background: #ef4444; border-radius: 50%; border: 2px solid #fff;
}
#tsacChatPanel {
    position: fixed; right: 20px; bottom: 88px; width: 320px;
    max-width: calc(100vw - 32px); height: 440px; max-height: calc(100vh - 120px);
    background: #fff; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
    display: flex; flex-direction: column; overflow: hidden; z-index: 1050;
}
.tsac-chat-head {
    background: #6366f1; color: #fff; padding: .75rem 1rem;
    display: flex; justify-content: space-between; align-items: center; flex-shrink: 0;
}
.tsac-chat-head strong { font-size: .9rem; }
.tsac-chat-head strong i { margin-right: .35rem; }
.tsac-chat-head-actions { display: flex; align-items: center; gap: .5rem; }
.tsac-chat-head-actions button { background: none; border: none; color: #fff; font-size: 1.1rem; line-height: 1; cursor: pointer; opacity: .9; }
.tsac-chat-head-actions button:hover { opacity: 1; }
#tsacChatClose { font-size: 1.3rem; }
.tsac-chat-preform { padding: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.tsac-chat-preform p { font-size: .82rem; color: #444; margin: 0 0 .25rem; }
.tsac-chat-preform input { border: 1px solid #dcdcdc; border-radius: 6px; padding: .5rem; font-size: .85rem; }
.tsac-chat-messages { flex: 1; overflow-y: auto; min-height: 0; padding: .75rem; font-size: .85rem; background: #f8f9fb; }
.tsac-chat-msg {
    margin-bottom: .6rem; max-width: 85%; padding: .45rem .65rem; border-radius: 10px;
    line-height: 1.35; white-space: pre-wrap; word-break: break-word;
}
.tsac-chat-msg.client { background: #6366f1; color: #fff; margin-left: auto; border-bottom-right-radius: 2px; }
.tsac-chat-msg.admin { background: #e9ecf2; color: #222; margin-right: auto; border-bottom-left-radius: 2px; }
.tsac-chat-msg time { display: block; font-size: .65rem; opacity: .7; margin-top: .2rem; }
.tsac-chat-msg img.tsac-chat-attachment-img { display: block; max-width: 100%; border-radius: 8px; margin-top: .3rem; cursor: pointer; }
.tsac-chat-attachment-file { display: flex; align-items: center; gap: .4rem; margin-top: .3rem; padding: .35rem .5rem; background: rgba(0,0,0,.08); border-radius: 6px; text-decoration: none; color: inherit; font-size: .78rem; }
.tsac-chat-msg.client .tsac-chat-attachment-file { background: rgba(255,255,255,.2); color: #fff; }
.tsac-chat-typing { padding: 0 .9rem .4rem; font-size: .72rem; color: #6b7280; font-style: italic; flex-shrink: 0; background: #f8f9fb; }
.tsac-chat-typing span::after { content: '...'; animation: tsacTypingDots 1.2s steps(4, end) infinite; }
@keyframes tsacTypingDots { 0%, 20% { content: '.'; } 40% { content: '..'; } 60%, 100% { content: '...'; } }
.tsac-chat-closed { padding: .6rem .9rem; font-size: .78rem; color: #6b7280; text-align: center; border-top: 1px solid #eee; flex-shrink: 0; }
.tsac-chat-form { display: flex; flex-direction: column; padding: .6rem; border-top: 1px solid #eee; flex-shrink: 0; }
.tsac-chat-form-row { display: flex; align-items: flex-end; gap: .4rem; }
.tsac-chat-form textarea {
    flex: 1; resize: none; border: 1px solid #dcdcdc; border-radius: 6px; padding: .4rem .5rem; font-size: .85rem;
    height: 38px; min-height: 38px; max-height: 100px; overflow-y: auto; line-height: 1.3;
}
.tsac-chat-form-row button[type="submit"], .tsac-chat-form-row #tsacChatAttachBtn, .tsac-chat-form-row #chatAttachBtn {
    background: #6366f1; color: #fff; border: none; border-radius: 6px; width: 38px; height: 38px; cursor: pointer; flex-shrink: 0;
}
.tsac-chat-form-row #tsacChatAttachBtn, .tsac-chat-form-row #chatAttachBtn { background: #eef0ff; color: #6366f1; }
.tsac-chat-form-row #tsacChatAttachBtn:hover, .tsac-chat-form-row #chatAttachBtn:hover { background: #e0e3ff; }
.tsac-chat-preview {
    display: flex; align-items: center; gap: .5rem; background: #f1f2f7; border-radius: 8px;
    padding: .4rem .5rem; margin-bottom: .4rem; font-size: .78rem;
}
.tsac-chat-preview-thumb { width: 36px; height: 36px; border-radius: 6px; overflow: hidden; flex-shrink: 0; background: #e0e3ff; display: flex; align-items: center; justify-content: center; color: #6366f1; }
.tsac-chat-preview-thumb img { width: 100%; height: 100%; object-fit: cover; }
.tsac-chat-preview-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #444; }
.tsac-chat-preview button { background: none; border: none; color: #888; cursor: pointer; font-size: .95rem; flex-shrink: 0; }
.tsac-chat-preview button:hover { color: #ef4444; }
@media (max-width: 480px) {
    #tsacChatPanel { right: 16px; left: 16px; width: auto; }
}

.tsac-chat-img-modal { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; }
.tsac-chat-img-modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .82); border: none; cursor: pointer; }
.tsac-chat-img-modal-content { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: .75rem; max-width: 92vw; }
.tsac-chat-img-modal-content img { max-width: 92vw; max-height: 78vh; border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.tsac-chat-img-modal-actions { display: flex; gap: .5rem; }
.tsac-chat-img-modal-actions .btn { display: inline-flex; align-items: center; gap: .35rem; }
