.agent-message-layout {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 8px;
    row-gap: 5px;
    padding: 0 !important;
    min-width: 0;
    text-align: left;
    box-sizing: border-box;
    width: 100%;
}

.uchat-chat-context,
.main .chat-body .chat-content,
.layim-chat-main,
#text,
#message,
#msg,
.layui-textarea,
div[contenteditable="true"],
.chat-attachment-drafts,
.chat-tab,
.chat-tab .layui-tab-content,
.chat-question,
.chat-iframe-writeCont {
    box-sizing: border-box;
}

.uchat-chat-context::-webkit-scrollbar,
.main .chat-body .chat-content::-webkit-scrollbar,
.layim-chat-main::-webkit-scrollbar,
#text::-webkit-scrollbar,
#message::-webkit-scrollbar,
#msg::-webkit-scrollbar,
.layui-textarea::-webkit-scrollbar,
div[contenteditable="true"]::-webkit-scrollbar,
.chat-attachment-drafts::-webkit-scrollbar,
.chat-tab::-webkit-scrollbar,
.chat-tab .layui-tab-content::-webkit-scrollbar,
.chat-question::-webkit-scrollbar,
.chat-iframe-writeCont::-webkit-scrollbar {
    width: 5px !important;
    height: 5px !important;
	background: transparent
}

.uchat-chat-context::-webkit-scrollbar-track,
.main .chat-body .chat-content::-webkit-scrollbar-track,
.layim-chat-main::-webkit-scrollbar-track,
#text::-webkit-scrollbar-track,
#message::-webkit-scrollbar-track,
#msg::-webkit-scrollbar-track,
.layui-textarea::-webkit-scrollbar-track,
div[contenteditable="true"]::-webkit-scrollbar-track,
.chat-attachment-drafts::-webkit-scrollbar-track,
.chat-tab::-webkit-scrollbar-track,
.chat-tab .layui-tab-content::-webkit-scrollbar-track,
.chat-question::-webkit-scrollbar-track,
.chat-iframe-writeCont::-webkit-scrollbar-track {
    background: transparent !important;
}

.uchat-chat-context::-webkit-scrollbar-thumb,
.main .chat-body .chat-content::-webkit-scrollbar-thumb,
.layim-chat-main::-webkit-scrollbar-thumb,
#text::-webkit-scrollbar-thumb,
#message::-webkit-scrollbar-thumb,
#msg::-webkit-scrollbar-thumb,
.layui-textarea::-webkit-scrollbar-thumb,
div[contenteditable="true"]::-webkit-scrollbar-thumb,
.chat-attachment-drafts::-webkit-scrollbar-thumb,
.chat-tab::-webkit-scrollbar-thumb,
.chat-tab .layui-tab-content::-webkit-scrollbar-thumb,
.chat-question::-webkit-scrollbar-thumb,
.chat-iframe-writeCont::-webkit-scrollbar-thumb {
    border-radius: 5px !important;
    background: #ccc !important;
}

.uchat-chat-context::-webkit-scrollbar-button,
.main .chat-body .chat-content::-webkit-scrollbar-button,
.layim-chat-main::-webkit-scrollbar-button,
#text::-webkit-scrollbar-button,
#message::-webkit-scrollbar-button,
#msg::-webkit-scrollbar-button,
.layui-textarea::-webkit-scrollbar-button,
div[contenteditable="true"]::-webkit-scrollbar-button,
.chat-attachment-drafts::-webkit-scrollbar-button,
.chat-tab::-webkit-scrollbar-button,
.chat-tab .layui-tab-content::-webkit-scrollbar-button,
.chat-question::-webkit-scrollbar-button,
.chat-iframe-writeCont::-webkit-scrollbar-button {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    background: transparent !important;
}

@supports (-moz-appearance: none) {
    .uchat-chat-context,
    .main .chat-body .chat-content,
    .layim-chat-main,
    #text,
    #message,
    #msg,
    .layui-textarea,
    div[contenteditable="true"],
    .chat-attachment-drafts,
    .chat-tab,
    .chat-tab .layui-tab-content,
    .chat-question,
    .chat-iframe-writeCont {
        scrollbar-width: thin;
        scrollbar-color: #ccc transparent;
    }
}

.uchat-chat-context {
    padding: 15px 15px 20px !important;
    overflow-x: hidden;
}

.main .chat-body .chat-content > .msglist {
    padding: 15px !important;
    overflow-x: hidden;
}

.uchat-chat-context .agent-message-layout,
.msglist .agent-message-layout {
    margin-top: 0 !important;
    margin-bottom: 10px !important;
}

.uchat-chat-context .agent-message-layout:last-of-type,
.msglist .agent-message-layout:last-of-type {
    margin-bottom: 0 !important;
}

.agent-message-layout.agent-message-mine {
    grid-template-columns: minmax(0, 1fr) auto;
}

.chat-item.agent-message-layout > .msg {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    min-width: 0;
    margin: 0 !important;
}

.chat-item.agent-message-layout .agent-message-main,
.chat-item.agent-message-layout .agent-message-avatar {
    grid-row: 1;
}

.chat-item.agent-message-layout .agent-message-main {
    max-width: 100% !important;
    padding: 0 !important;
}

.chat-item.agent-message-layout .agent-message-header {
    flex-wrap: nowrap !important;
    gap: 6px !important;
    white-space: nowrap;
}

.chat-item.agent-message-layout .agent-message-header .mineTop,
.chat-item.agent-message-layout .agent-message-header .mineTop span {
    display: inline !important;
    white-space: nowrap !important;
}

.chat-item.agent-message-layout .agent-message-header .mineTop {
    display: block !important;
    color: inherit;
    font-size: inherit;
    line-height: inherit;
}

.agent-message-layout .agent-message-header {
    grid-column: 1 / -1;
    grid-row: 1;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    color: #999;
    font-size: 12px;
    line-height: 18px;
    text-align: left;
}

.agent-message-layout .agent-message-header .date-time,
.agent-message-layout .agent-message-header cite {
    position: static !important;
    display: inline !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    color: inherit;
    font-size: inherit;
    font-style: normal;
    white-space: nowrap !important;
}

.agent-message-layout .agent-message-avatar {
    grid-column: 1;
    grid-row: 2;
    position: static !important;
    align-self: start;
    width: 40px !important;
    margin: 0 !important;
    padding: 0 !important;
    text-align: center !important;
}

.agent-message-layout .agent-message-avatar img {
    position: static !important;
    display: block;
    width: 40px !important;
    height: 40px !important;
    margin: 0 !important;
    border-radius: 4px;
    object-fit: cover;
}

.agent-message-layout .agent-message-read {
    position: static !important;
    display: block !important;
    float: none !important;
    width: auto !important;
    margin: 4px 0 0 !important;
    font-size: 11px;
    line-height: 16px;
    white-space: nowrap;
    text-align: center;
}

.agent-message-layout .agent-message-read.active {
    color: #999 !important;
}

.chat-item.agent-message-layout .agent-message-read.active {
    color: #bbb !important;
}

.agent-message-layout .agent-message-main {
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
    align-self: start;
    margin: 0 !important;
    padding: 0 !important;
}

.agent-message-layout .agent-message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    max-width: 100%;
}

.agent-message-layout .agent-message-row {
    display: flex;
    align-items: flex-start !important;
    justify-content: flex-start;
    gap: 8px;
    min-width: 0;
    max-width: 100%;
}

.agent-message-layout .agent-message-row > .agent-message-bubble {
    align-self: flex-start !important;
}

.agent-message-layout .agent-message-bubble {
    position: relative;
    display: flex !important;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-height: 40px;
    float: none !important;
    flex: 0 1 auto;
    box-sizing: border-box;
    min-width: 0;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 2px 8px !important;
    border: 0 !important;
    border-radius: 6px !important;
    background: #f1f1f1 !important;
    color: #333 !important;
    line-height: 1.6;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.agent-message-layout .agent-message-bubble > p,
.agent-message-layout .agent-message-bubble > pre {
    margin-top: 0;
    margin-bottom: 0;
}

#text[contenteditable="true"],
#message[contenteditable="true"],
#msg[contenteditable="true"] {
    color: #333 !important;
    font-family: inherit;
}

#text[contenteditable="true"] [style],
#message[contenteditable="true"] [style],
#msg[contenteditable="true"] [style] {
    color: inherit !important;
    background: transparent !important;
    font-family: inherit !important;
    font-size: inherit !important;
}

.chat-attachment-drafts {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
    padding: 7px 10px;
    overflow-x: auto;
    overflow-y: hidden;
    border-top: 1px solid #eee;
    background: #fff;
	z-index: 100;
}

.chat-attachment-drafts[hidden],
.chat-attachment-draft[hidden] {
    display: none !important;
}

.chat-attachment-draft {
    position: relative;
    box-sizing: border-box;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    max-width: 190px;
    height: 52px;
    border: 1px solid #eee;
    border-radius: 5px;
    background: #f4f4f4;
}

.chat-attachment-image { width: 52px; }
.chat-attachment-image img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; }
.chat-attachment-file { width: 190px; padding: 6px 22px 6px 7px; gap: 6px; }
.chat-attachment-icon { display: flex; align-items: center; justify-content: center; flex: 0 0 35px; height: 36px; border-radius: 3px; background: #e69553; color: #fff; font-size: 10px; font-weight: 700; }
.chat-attachment-details { display: flex; flex-direction: column; min-width: 0; line-height: 17px; }
.chat-attachment-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.chat-attachment-size { color: #999; font-size: 10px; }
.chat-attachment-remove { position: absolute; top: -5px; right: -5px; display: flex; align-items: center; justify-content: center; width: 17px; height: 17px; padding: 0; border: 0; border-radius: 50%; background: #666; color: #fff; cursor: pointer; font-size: 14px; line-height: 1; }
.chat-attachment-sending { opacity: .6; }

.uchat-chat-footer .chat-attachment-drafts { position: absolute; bottom: 100%; left: 0; }
.uchat-chat-footer > .chat-attachment-drafts { width: 100%; }
.uchat-chat-footer { overflow: visible !important; }
.uchat-chat-footer > .visitor-quote-preview:not([hidden]) {
    position: absolute;
    left: 0;
    bottom: 100%;
    width: 100%;
    z-index: 2;
}
.uchat-chat-footer:has(> .chat-attachment-drafts:not([hidden])) > .visitor-quote-preview:not([hidden]) {
    bottom: calc(100% + 74px);
}
.chat-footer .chat-attachment-drafts { margin-bottom: 7px; }
.layim-chat-footer .chat-attachment-drafts { position: absolute; bottom: 100%; left: 0; }
.main .chat-body .chat-content:has(+ .chat-footer .chat-attachment-drafts:not([hidden])) { padding-bottom: 70px !important; }
.layim-chat-main:has(+ .layim-chat-footer .chat-attachment-drafts:not([hidden])) { bottom: 150px !important; }

.agent-message-layout .agent-message-bubble .chat-content,
.agent-message-layout .agent-message-bubble pre {
    color: inherit !important;
    font-family: inherit;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.agent-withdrawn > p,
.visitor-withdrawn > p {
    grid-column: 1 / -1;
    margin: 8px 0;
    color: #999;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
}

.agent-message-layout .agent-message-bubble::before,
.agent-message-layout .agent-message-bubble::after {
    display: none !important;
}

.agent-message-layout .agent-message-bubble::before {
    display: block !important;
    content: "" !important;
    position: absolute;
    top: 12px;
    left: -6px;
    width: 0;
    height: 0;
    border: 6px solid transparent;
    border-left: 0;
    border-right-color: #f1f1f1;
}

.agent-message-layout.agent-message-mine .agent-message-bubble::before {
    left: auto;
    right: -6px;
    border-right: 0;
    border-left: 6px solid var(--agent-message-send-color, #1e9fff);
}

.agent-message-layout .agent-message-bubble img,
.agent-message-layout .agent-message-bubble video {
    max-width: 100%;
    object-fit: contain;
}

.agent-message-layout.agent-message-mine .agent-message-header {
    justify-content: flex-end;
    text-align: right;
}

.agent-message-layout.agent-message-mine .agent-message-avatar {
    grid-column: 2;
}

.agent-message-layout.agent-message-mine .agent-message-main {
    grid-column: 1;
}

.agent-message-layout.agent-message-mine .agent-message-content {
    align-items: flex-end;
}

.agent-message-layout.agent-message-mine .agent-message-row {
    justify-content: flex-end;
}

.agent-message-layout.agent-message-mine .agent-message-bubble {
    background: var(--agent-message-send-color, #1e9fff) !important;
    color: var(--agent-message-send-text-color, #fff) !important;
}

.agent-message-layout.agent-message-mine .agent-message-bubble a {
    color: inherit;
    text-decoration: underline;
}

.agent-message-layout .agent-message-quote {
    box-sizing: border-box;
    max-width: 100%;
    margin-top: 5px;
    padding: 5px 8px;
    border-left: 2px solid #ccc;
    border-radius: 3px;
    background: #f5f5f5;
    color: #888;
    font-size: 12px;
    line-height: 18px;
    overflow-wrap: anywhere;
    text-align: left;
}

.agent-message-layout .agent-message-actions {
    display: inline-flex !important;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    gap: 4px;
    max-width: none;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.agent-message-layout .agent-message-actions button {
    appearance: none;
    margin: 0;
    padding: 3px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    color: #666;
    font: inherit;
    font-size: 12px;
    line-height: 18px;
    white-space: nowrap;
    cursor: pointer;
    touch-action: manipulation;
}

.agent-message-layout .agent-message-actions button:hover,
.agent-message-layout .agent-message-actions button:focus-visible {
    border-color: var(--agent-message-send-color, #1e9fff);
    color: var(--agent-message-send-color, #1e9fff);
}

.agent-message-layout.agent-message-actions-open .agent-message-actions {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

@media (hover: hover) and (pointer: fine) {
    .agent-message-layout:hover .agent-message-actions,
    .agent-message-layout:focus-within .agent-message-actions {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
}

@media (max-width: 480px) {
    .agent-message-layout .agent-message-row {
        gap: 5px !important;
    }

    .agent-message-layout .agent-message-actions {
        max-width: none;
    }
}

.layui-layer.uchat-image-preview {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: none !important;
    max-height: none !important;
    box-sizing: border-box !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: hidden !important;
}
.uchat-image-preview .layui-layer-content {
    height: 100% !important;
    max-height: none !important;
    overflow: hidden !important;
}
.uchat-preview-mount { width: 100%; height: 100%; }
.uchat-preview-panel { position: relative; width: 100%; height: 100%; }
.uchat-preview-stage { display: flex; align-items: safe center; justify-content: safe center; width: 100%; height: 100%; box-sizing: border-box; padding: 60px 24px 78px; overflow: auto; touch-action: pan-x pan-y; scrollbar-width: thin; scrollbar-color: #666 transparent; }
.uchat-image-preview .uchat-preview-stage img { display: block; flex: none; width: auto; height: auto; max-width: none !important; max-height: none !important; object-fit: contain; user-select: none; cursor: default; }
.uchat-preview-draggable img { cursor: grab !important; }
.uchat-preview-dragging img { cursor: grabbing !important; }
.uchat-preview-toolbar { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 10; display: flex; justify-content: center; align-items: center; gap: 8px; min-height: 44px; padding: 4px 10px; box-sizing: border-box; color: #fff; background: rgba(45, 49, 55, .8); border: 1px solid rgba(255, 255, 255, .2); border-radius: 24px; box-shadow: 0 5px 24px rgba(0, 0, 0, .24); backdrop-filter: blur(10px); white-space: nowrap; }
.uchat-preview-toolbar button { min-width: 34px; height: 32px; padding: 0 8px; border: 0; border-radius: 16px; background: transparent; color: #fff; cursor: pointer; transition: background .15s ease; }
.uchat-preview-toolbar button:hover { background: rgba(255, 255, 255, .18); }
.uchat-preview-percent { min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; }
.uchat-image-preview .layui-layer-setwin { position: absolute !important; top: 16px !important; right: 16px !important; left: auto !important; width: 40px !important; height: 40px !important; box-sizing: border-box !important; z-index: 20 !important; background: rgba(65, 67, 71, .76) !important; border: 1px solid rgba(255, 255, 255, .28); border-radius: 50% !important; box-shadow: 0 2px 12px rgba(0, 0, 0, .2); }
.uchat-image-preview .layui-layer-setwin .layui-layer-close { position: absolute !important; inset: 0 !important; margin: 0 !important; display: block !important; width: 100% !important; height: 100% !important; background: none !important; font-size: 0 !important; }
.uchat-image-preview .layui-layer-setwin .layui-layer-close::after { content: '\00d7'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: #fff; font: 24px/1 Arial, sans-serif; }
