.dles-livechat {
    --lc-accent: var(--lc-primary, var(--primary, #30caff));
    --lc-accent2: var(--primary2, #0ea5e9);
    --lc-panel: var(--surface, #21283b);
    --lc-card: var(--card-bg, #21283b);
    --lc-border: var(--card-border, var(--border, rgba(148,163,184,.18)));
    --lc-text: var(--text, #e5e7eb);
    --lc-muted: var(--muted2, rgba(226,232,240,.72));
    --lc-shadow: var(--shadow, 0 10px 25px rgba(15,23,42,.30));
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 15000;
    font-family: 'Roboto', 'Segoe UI Emoji', sans-serif;
    color: var(--lc-text);
    font-size: 14px;
    line-height: 1.4;
}
.dles-livechat * { box-sizing: border-box; }
.dles-livechat button,
.dles-livechat input,
.dles-livechat textarea { font: inherit; }

.dles-livechat__launcher {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    border: 1px solid var(--lc-border);
    background: linear-gradient(135deg, var(--lc-accent), var(--lc-accent2));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    box-shadow: 0 12px 28px color-mix(in srgb, var(--lc-accent) 24%, rgba(0,0,0,.28));
    transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.dles-livechat__launcher:hover { transform: translateY(-1px); filter: brightness(1.04); box-shadow: var(--lc-shadow); }
.dles-livechat__launcher:focus-visible { outline: 2px solid color-mix(in srgb, var(--lc-accent) 65%, #fff); outline-offset: 3px; }
.dles-livechat__launcher svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.dles-livechat__launcher-close { display: none; }
.dles-livechat.is-open .dles-livechat__launcher-icon { display: none; }
.dles-livechat.is-open .dles-livechat__launcher-close { display: flex; }

.dles-livechat__badge {
    position: absolute;
    right: -5px;
    top: -5px;
    min-width: 21px;
    height: 21px;
    padding: 0 6px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    border: 2px solid var(--bg, #141425);
    font-size: 10px;
    font-weight: 800;
    line-height: 17px;
    text-align: center;
}
.dles-livechat__badge[hidden] { display: none; }

.dles-livechat__presence-dot {
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #f59e0b;
    border: 3px solid var(--bg, #141425);
}
.dles-livechat.is-online .dles-livechat__presence-dot { background: #4caf50; }

.dles-livechat__teaser {
    position: absolute;
    right: 0;
    bottom: 76px;
    width: min(300px, calc(100vw - 36px));
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 13px 14px;
    border: 1px solid var(--lc-border);
    border-radius: var(--card-radius, 12px);
    background: color-mix(in srgb, var(--lc-card) 92%, rgba(255,255,255,.06));
    color: var(--lc-text);
    box-shadow: 0 18px 40px rgba(0,0,0,.28);
    text-align: left;
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: lcTeaserIn .3s ease;
}
.dles-livechat__teaser strong { font-size: 13px; line-height: 1.3; }
.dles-livechat__teaser span { font-size: 12px; line-height: 1.45; color: var(--lc-muted); }
.dles-livechat__teaser:hover { border-color: color-mix(in srgb, var(--lc-accent) 35%, var(--lc-border)); }
.dles-livechat__teaser[hidden],
.dles-livechat.is-open .dles-livechat__teaser { display: none; }
@keyframes lcTeaserIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.dles-livechat__panel {
    position: absolute;
    right: 0;
    bottom: 74px;
    width: min(390px, calc(100vw - 28px));
    height: min(610px, calc(100vh - 115px));
    background: var(--lc-card);
    border: 1px solid var(--lc-border);
    border-radius: var(--card-radius, 12px);
    box-shadow: 0 24px 70px rgba(0,0,0,.38);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(.985);
    transform-origin: bottom right;
    transition: opacity .18s ease, transform .18s ease, visibility .18s;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}
html[data-theme="light"] .dles-livechat__panel { box-shadow: 0 22px 55px rgba(15,23,42,.18); }
.dles-livechat.is-open .dles-livechat__panel { opacity: 1; visibility: visible; transform: none; }

.dles-livechat__header {
    min-height: 72px;
    padding: 12px 13px 12px 14px;
    display: flex;
    align-items: center;
    gap: 11px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--lc-accent) 18%, var(--lc-panel)), color-mix(in srgb, var(--lc-accent2) 10%, var(--lc-panel)));
    border-bottom: 1px solid var(--lc-border);
}
.dles-livechat__avatar {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--lc-accent), var(--lc-accent2));
    box-shadow: 0 8px 18px color-mix(in srgb, var(--lc-accent) 20%, transparent);
    position: relative;
    color: #fff;
}
.dles-livechat__avatar svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.dles-livechat__avatar-status {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #f59e0b;
    border: 3px solid var(--lc-panel);
}
.dles-livechat.is-online .dles-livechat__avatar-status { background: #4caf50; }
.dles-livechat__header-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.dles-livechat__title { font-size: 14px; line-height: 1.25; color: var(--lc-text); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dles-livechat__status { font-size: 11px; color: var(--lc-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dles-livechat.is-online .dles-livechat__status { color: #65c96a; }
.dles-livechat__header-actions { display: flex; gap: 4px; }
.dles-livechat__header-actions button {
    width: 34px;
    height: 34px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: rgba(255,255,255,.04);
    color: var(--lc-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.dles-livechat__header-actions button:hover { background: rgba(255,255,255,.08); border-color: var(--lc-border); color: var(--lc-text); }
html[data-theme="light"] .dles-livechat__header-actions button { background: rgba(15,23,42,.035); }
html[data-theme="light"] .dles-livechat__header-actions button:hover { background: rgba(15,23,42,.07); }
.dles-livechat__header-actions svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.dles-livechat__sound .sound-off { display: none; }
.dles-livechat.is-muted .dles-livechat__sound .sound-on { display: none; }
.dles-livechat.is-muted .dles-livechat__sound .sound-off { display: block; }

.dles-livechat__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 13px 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--color-highlight-background, #4f535f) transparent;
}
.dles-livechat__body::-webkit-scrollbar { width: 6px; }
.dles-livechat__body::-webkit-scrollbar-track { background: transparent; }
.dles-livechat__body::-webkit-scrollbar-thumb { background: var(--color-highlight-background, #4f535f); border-radius: 10px; }

.dles-livechat__welcome {
    margin: 2px 1px 16px;
    padding: 14px;
    border-radius: var(--card-radius, 12px);
    background: rgba(255,255,255,.045);
    border: 1px solid var(--lc-border);
    text-align: left;
}
html[data-theme="light"] .dles-livechat__welcome { background: rgba(255,255,255,.72); }
.dles-livechat.has-conversation .dles-livechat__welcome { display: none; }
.dles-livechat__welcome-icon {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--lc-accent) 22%, transparent), color-mix(in srgb, var(--lc-accent2) 18%, transparent));
    color: var(--lc-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 9px;
    border: 1px solid color-mix(in srgb, var(--lc-accent) 20%, transparent);
}
.dles-livechat__welcome-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.dles-livechat__welcome strong { display: block; font-size: 13px; color: var(--lc-text); margin-bottom: 5px; }
.dles-livechat__welcome p { margin: 0; color: var(--lc-muted); font-size: 12px; line-height: 1.5; }

.dles-livechat__messages { display: flex; flex-direction: column; gap: 9px; }
.dles-livechat__message { max-width: 84%; display: flex; flex-direction: column; gap: 4px; animation: lcMessageIn .18s ease; }
@keyframes lcMessageIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.dles-livechat__message--visitor { align-self: flex-end; align-items: flex-end; }
.dles-livechat__message--admin,
.dles-livechat__message--system { align-self: flex-start; align-items: flex-start; }
.dles-livechat__bubble { padding: 9px 11px; border-radius: 12px; font-size: 12px; line-height: 1.48; word-break: break-word; white-space: pre-wrap; }
.dles-livechat__message--visitor .dles-livechat__bubble { background: linear-gradient(135deg, var(--lc-accent), var(--lc-accent2)); color: #fff; border-bottom-right-radius: 4px; }
.dles-livechat__message--admin .dles-livechat__bubble,
.dles-livechat__message--system .dles-livechat__bubble { background: rgba(255,255,255,.055); color: var(--lc-text); border: 1px solid var(--lc-border); border-bottom-left-radius: 4px; }
html[data-theme="light"] .dles-livechat__message--admin .dles-livechat__bubble,
html[data-theme="light"] .dles-livechat__message--system .dles-livechat__bubble { background: #fff; }
.dles-livechat__meta { font-size: 9px; color: var(--lc-muted); opacity: .72; padding: 0 3px; display: flex; gap: 5px; }

.dles-livechat__file-link {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 7px;
    padding: 8px 9px;
    border-radius: 9px;
    background: rgba(0,0,0,.10);
    color: inherit;
    text-decoration: none;
    border: 1px solid rgba(255,255,255,.10);
    max-width: 100%;
}
.dles-livechat__file-link:hover { background: rgba(255,255,255,.07); color: inherit; }
.dles-livechat__file-link svg { width: 17px; height: 17px; flex: 0 0 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.dles-livechat__file-copy { min-width: 0; }
.dles-livechat__file-copy strong { display: block; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dles-livechat__file-copy small { font-size: 9px; opacity: .7; }

.dles-livechat__typing[hidden] { display: none !important; }
.dles-livechat__typing {
    display: flex;
    align-items: center;
    gap: 4px;
    width: max-content;
    margin-top: 10px;
    padding: 7px 10px;
    border-radius: 10px;
    background: rgba(255,255,255,.05);
    border: 1px solid var(--lc-border);
    color: var(--lc-muted);
}
.dles-livechat__typing span { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: lcTyping 1.1s infinite ease-in-out; }
.dles-livechat__typing span:nth-child(2) { animation-delay: .14s; }
.dles-livechat__typing span:nth-child(3) { animation-delay: .28s; }
@keyframes lcTyping { 0%,60%,100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-3px); opacity: 1; } }
.dles-livechat__typing em { font-style: normal; font-size: 10px; margin-left: 3px; }

.dles-livechat__identity {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    margin: 0 12px 8px 59px;
    padding: 0;
    background: transparent;
}
.dles-livechat__identity input {
    width: 100%;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--lc-border);
    background: rgba(255,255,255,.055);
    color: var(--lc-text);
    padding: 0 12px;
    font-size: 11px;
    outline: none;
    box-shadow: none;
}
html[data-theme="light"] .dles-livechat__identity input { background: #fff; }
.dles-livechat__identity input::placeholder { color: var(--lc-muted); }
.dles-livechat__identity input:focus { border-color: var(--lc-accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--lc-accent) 14%, transparent); }

.dles-livechat__file-preview {
    margin: 0 12px 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(255,255,255,.055);
    border: 1px solid var(--lc-border);
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--lc-muted);
    font-size: 11px;
}
.dles-livechat__file-preview[hidden] { display: none; }
.dles-livechat__file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.dles-livechat__file-remove { width: 22px; height: 22px; border: 1px solid var(--lc-border); border-radius: 7px; background: rgba(255,255,255,.05); color: var(--lc-text); cursor: pointer; }

.dles-livechat__composer {
    min-height: 62px;
    padding: 0 10px 10px 11px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--lc-card);
}
.dles-livechat__attach,
.dles-livechat__send {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s, color .15s, transform .12s, border-color .15s;
}
.dles-livechat__attach { color: var(--lc-muted); background: rgba(255,255,255,.045); border: 1px solid var(--lc-border); margin: 0 !important; padding: 0 !important; align-self: center !important; line-height: 1 !important; vertical-align: middle !important; position: static !important; top: auto !important; bottom: auto !important; }
.dles-livechat__attach:hover { background: rgba(255,255,255,.09); color: var(--lc-text); border-color: color-mix(in srgb, var(--lc-accent) 45%, var(--lc-border)); }
.dles-livechat__attach input { display: none; }
.dles-livechat__attach svg,
.dles-livechat__send svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dles-livechat__input {
    flex: 1;
    min-width: 0;
    max-height: 102px;
    min-height: 40px;
    resize: none;
    border: 1px solid var(--lc-border);
    background: rgba(255,255,255,.055);
    color: var(--lc-text);
    border-radius: 12px;
    padding: 9px 11px;
    line-height: 20px;
    font-size: 12px;
    outline: none;
    overflow-y: auto;
    box-shadow: none;
    margin: 0 !important;
    align-self: center !important;
}
html[data-theme="light"] .dles-livechat__input { background: #fff; }
.dles-livechat__input::placeholder { color: var(--lc-muted); }
.dles-livechat__input:focus { border-color: var(--lc-accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--lc-accent) 12%, transparent); }
.dles-livechat__send { border: 0; background: linear-gradient(135deg, var(--lc-accent), var(--lc-accent2)); color: #fff; margin: 0 !important; padding: 0 !important; align-self: center !important; }
.dles-livechat__send:hover { filter: brightness(1.05); transform: translateY(-1px); }
.dles-livechat__send:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.dles-livechat__footer-line {
    min-height: 28px;
    padding: 0 11px 9px;
    background: var(--lc-card);
    color: var(--lc-muted);
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.dles-livechat__finish { border: 0; background: none; color: var(--lc-accent); font-size: 9px; padding: 2px 0; cursor: pointer; }
.dles-livechat__finish:hover { text-decoration: underline; }
.dles-livechat.is-blocked .dles-livechat__composer,
.dles-livechat.is-blocked .dles-livechat__identity,
.dles-livechat.is-blocked .dles-livechat__file-preview { display: none !important; }

.dles-livechat__error {
    margin: 8px 1px;
    padding: 9px 10px;
    border-radius: 10px;
    background: rgba(239,68,68,.10);
    border: 1px solid rgba(239,68,68,.24);
    color: #fca5a5;
    font-size: 11px;
    line-height: 1.4;
}
html[data-theme="light"] .dles-livechat__error { color: #b42318; background: #fff1f0; }

@media (max-width: 600px) {
    .dles-livechat { right: 12px; bottom: 12px; }
    .dles-livechat__launcher { width: 56px; height: 56px; border-radius: 15px; }
    .dles-livechat__teaser {
        right: 0;
        bottom: 70px;
        width: min(280px, calc(100vw - 30px));
    }
    .dles-livechat__panel {
        position: fixed;
        right: 8px;
        left: 8px;
        bottom: 76px;
        width: auto;
        height: min(640px, calc(100dvh - 94px));
        border-radius: var(--card-radius, 12px);
        transform-origin: bottom center;
    }
    .dles-livechat__header { min-height: 68px; padding: 11px; }
    .dles-livechat__body { padding: 12px 10px 8px; }
}
@media (max-width: 430px) {
    .dles-livechat__identity { grid-template-columns: 1fr; margin: 0 12px 8px; }
}
@media (prefers-reduced-motion: reduce) {
    .dles-livechat__panel,
    .dles-livechat__launcher,
    .dles-livechat__message,
    .dles-livechat__teaser { transition: none; animation: none; }
    .dles-livechat__typing span { animation: none; }
}


.dles-livechat__confirm-modal {
    z-index: 16020;
}
.dles-livechat__confirm-modal .modal-content {
    max-width: 460px;
    margin: 90px auto;
}
.dles-livechat__confirm-text {
    margin: 0 0 18px;
    color: var(--text, var(--lc-text));
    font-size: 14px;
    line-height: 1.6;
}
.dles-livechat__confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}
.dles-livechat__confirm-actions .btn-primary,
.dles-livechat__confirm-actions .btn-ghost {
    min-width: 150px;
    justify-content: center;
}
@media (max-width: 600px) {
    .dles-livechat__confirm-modal .modal-content {
        width: calc(100% - 20px);
        margin: 60px auto;
    }
    .dles-livechat__confirm-actions {
        flex-direction: column-reverse;
    }
    .dles-livechat__confirm-actions .btn-primary,
    .dles-livechat__confirm-actions .btn-ghost {
        width: 100%;
        min-width: 0;
    }
}
