#mlc-widget {
    --mlc-primary: #4f46e5;
    --mlc-accent: #7c3aed;
    --mlc-ink: #111827;
    --mlc-muted: #64748b;
    --mlc-border: #e2e8f0;
    isolation: isolate;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.45;
    color: var(--mlc-ink);
    z-index: 99999;
}
#mlc-widget *, #mlc-widget *::before, #mlc-widget *::after { box-sizing: border-box; }
#mlc-widget [hidden] { display: none !important; }

#mlc-button {
    appearance: none;
    position: fixed;
    right: 24px;
    bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 62px;
    height: 62px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(140deg, var(--mlc-primary), var(--mlc-accent));
    color: #fff;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(79, 70, 229, .34);
    box-shadow: 0 8px 24px color-mix(in srgb, var(--mlc-primary) 34%, transparent);
    transition: transform .18s ease, box-shadow .18s ease;
    z-index: 100000;
    animation: mlcPulse 4s ease-in-out infinite;
}
#mlc-button:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(79, 70, 229, .4); box-shadow: 0 12px 30px color-mix(in srgb, var(--mlc-primary) 40%, transparent); }
#mlc-button:focus-visible, #mlc-widget button:focus-visible, #mlc-widget input:focus-visible, #mlc-widget textarea:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--mlc-primary) 40%, white);
    outline-offset: 3px;
}
.mlc-launcher-label {
    position: absolute;
    right: 72px;
    padding: 7px 10px;
    border-radius: 8px;
    background: #111827;
    color: #fff;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(5px);
    pointer-events: none;
    transition: opacity .16s ease, transform .16s ease;
}
#mlc-button:hover .mlc-launcher-label, #mlc-button:focus-visible .mlc-launcher-label { opacity: 1; transform: translateX(0); }
@keyframes mlcPulse { 0%, 100% { box-shadow: 0 8px 24px rgba(79, 70, 229, .3); box-shadow: 0 8px 24px color-mix(in srgb, var(--mlc-primary) 30%, transparent); } 50% { box-shadow: 0 8px 30px rgba(79, 70, 229, .45); box-shadow: 0 8px 30px color-mix(in srgb, var(--mlc-primary) 45%, transparent); } }

#mlc-window {
    position: fixed;
    right: 24px;
    bottom: 102px;
    display: none;
    flex-direction: column;
    width: 390px;
    height: min(600px, calc(100vh - 130px));
    max-width: calc(100vw - 32px);
    overflow: hidden;
    border: 1px solid rgba(226, 232, 240, .9);
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .22), 0 3px 12px rgba(15, 23, 42, .08);
    z-index: 100000;
    transform-origin: bottom right;
    animation: mlcSlideUp .22s ease-out;
}
@keyframes mlcSlideUp { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

#mlc-widget[data-position="bottom-left"] #mlc-button,
#mlc-widget[data-position="bottom-left"] #mlc-window { right: auto; left: 24px; }
#mlc-widget[data-position="bottom-left"] .mlc-launcher-label { right: auto; left: 72px; transform: translateX(-5px); }
#mlc-widget[data-position="bottom-left"] #mlc-button:hover .mlc-launcher-label,
#mlc-widget[data-position="bottom-left"] #mlc-button:focus-visible .mlc-launcher-label { transform: translateX(0); }
#mlc-widget[data-position="bottom-left"] #mlc-window { transform-origin: bottom left; }

#mlc-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 17px 18px;
    color: #fff;
    background: linear-gradient(125deg, var(--mlc-primary), var(--mlc-accent));
}
.mlc-header-info { display: flex; align-items: center; gap: 11px; min-width: 0; }
.mlc-avatar {
    display: grid;
    place-items: center;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
}
.mlc-header-info strong { display: block; max-width: 245px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.mlc-status { display: flex; align-items: center; gap: 6px; margin-top: 2px; color: rgba(255,255,255,.9); font-size: 12px; }
.mlc-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #4ade80; }
.mlc-status.is-offline::before { background: #fbbf24; }
#mlc-close {
    display: grid;
    place-items: center;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255,255,255,.14);
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}
#mlc-close:hover { background: rgba(255,255,255,.25); }

#mlc-messages {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    padding: 18px 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #f8fafc;
    scroll-behavior: smooth;
}
.mlc-msg {
    position: relative;
    max-width: 82%;
    padding: 10px 13px 8px;
    border: 1px solid transparent;
    border-radius: 16px;
    line-height: 1.5;
    overflow-wrap: anywhere;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.mlc-msg.admin { align-self: flex-start; border-color: #e2e8f0; border-bottom-left-radius: 5px; background: #fff; color: #1f2937; }
.mlc-msg.visitor { align-self: flex-end; border-bottom-right-radius: 5px; background: linear-gradient(135deg, var(--mlc-primary), var(--mlc-accent)); color: #fff; }
.mlc-msg.system { align-self: center; max-width: 94%; border-color: #fed7aa; background: #fff7ed; color: #9a3412; font-size: 12px; }
.mlc-msg img { display: block; max-width: 220px; max-height: 190px; margin-top: 7px; border-radius: 10px; object-fit: contain; }
.mlc-msg-time { display: block; margin-top: 4px; opacity: .65; font-size: 10px; line-height: 1.2; }

#mlc-start {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    padding: 24px 20px;
    overflow-y: auto;
    background: #fff;
    text-align: center;
}
#mlc-start h2 { margin: 0 0 5px; color: #111827; font-size: 20px; line-height: 1.3; }
#mlc-start input, #mlc-start textarea {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 11px 13px;
    border: 1px solid #cbd5e1;
    border-radius: 11px;
    background: #fff;
    color: #111827;
    font: inherit;
    box-shadow: none;
}
#mlc-start textarea { min-height: 92px; resize: vertical; }
#mlc-start-status { min-height: 18px; color: #b91c1c; font-size: 12px; }
#mlc-start-status:not(.is-error) { color: #64748b; }
.mlc-step-label { align-self: center; padding: 5px 10px; border-radius: 999px; background: #f1e9ff; color: #6d37ce; font-size: 11px; font-weight: 700; }

#mlc-input-area {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}
#mlc-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 44px;
    padding: 0 15px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #f8fafc;
    color: #111827;
    font: inherit;
    box-shadow: none;
}
#mlc-input:focus { border-color: var(--mlc-primary); background: #fff; }
#mlc-attach, #mlc-send, .mlc-btn {
    appearance: none;
    flex: 0 0 auto;
    min-height: 42px;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
    font-weight: 650;
    transition: filter .15s ease, transform .15s ease;
}
#mlc-attach { width: 42px; background: #eef2ff; color: var(--mlc-primary); font-size: 25px; line-height: 1; }
#mlc-send, .mlc-btn { padding: 0 17px; background: linear-gradient(135deg, var(--mlc-primary), var(--mlc-accent)); color: #fff; }
#mlc-attach:hover, #mlc-send:hover, .mlc-btn:hover { filter: brightness(1.04); transform: translateY(-1px); }
#mlc-send:disabled, .mlc-btn:disabled { opacity: .55; cursor: wait; transform: none; }
.mlc-visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }

#mlc-welcome-teaser {
    position: fixed;
    right: 24px;
    bottom: 100px;
    display: flex;
    align-items: flex-start;
    gap: 7px;
    width: min(340px, calc(100vw - 32px));
    z-index: 100001;
    animation: mlcSlideUp .22s ease-out;
}
#mlc-welcome-teaser[hidden] { display: none !important; }
#mlc-welcome-open {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: 11px;
    min-width: 0;
    padding: 13px 15px;
    border: 1px solid #e5e7eb;
    border-radius: 15px;
    background: #fff;
    color: #1f2937;
    text-align: left;
    box-shadow: 0 12px 34px rgba(15, 23, 42, .16);
    cursor: pointer;
}
.mlc-welcome-agent { display: grid; flex: 0 0 34px; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: linear-gradient(135deg, var(--mlc-primary), var(--mlc-accent)); color: #fff; font-weight: 700; }
.mlc-welcome-copy { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
#mlc-welcome-dismiss { display: grid; flex: 0 0 27px; width: 27px; height: 27px; place-items: center; padding: 0; border: 0; border-radius: 50%; background: #e9edf4; color: #475569; font-size: 19px; cursor: pointer; }
#mlc-widget[data-position="bottom-left"] #mlc-welcome-teaser { right: auto; left: 24px; }

@media (max-width: 480px) {
    #mlc-window { right: 8px; left: 8px; bottom: 84px; width: auto; max-width: none; height: min(620px, calc(100vh - 104px)); height: min(620px, calc(100dvh - 104px)); border-radius: 20px; }
    #mlc-button { right: 16px; bottom: 16px; width: 58px; height: 58px; }
    #mlc-widget[data-position="bottom-left"] #mlc-button { right: auto; left: 16px; }
    #mlc-widget[data-position="bottom-left"] #mlc-window { right: 8px; left: 8px; }
    #mlc-widget[data-position="bottom-left"] .mlc-launcher-label { left: 68px; }
    #mlc-welcome-teaser { right: 8px; bottom: 84px; }
    #mlc-widget[data-position="bottom-left"] #mlc-welcome-teaser { right: auto; left: 8px; }
}
@media (prefers-reduced-motion: reduce) {
    #mlc-button, #mlc-window, #mlc-widget * { animation: none !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
