.ec-chat-widget[hidden] { display: none; }
.ec-chat-widget {
    position: fixed;
    inset: auto max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom), var(--ec-chat-obstruction-offset, 0px)) auto;
    z-index: 5500;
}

.ec-chat-widget:has(> .ec-chat-widget__panel:not([hidden])) {
    z-index: 2147483647;
}

.ec-chat-widget__toggle {
    position: relative;
    display: grid;
    place-items: center;
    width: 3.5rem;
    height: 3.5rem;
    border: 1px solid rgb(255 255 255 / .24);
    border-radius: 50%;
    background: var(--ec-chat-accent, #135c77);
    color: var(--ec-chat-action-text, #fff);
    box-shadow: 0 .4rem 1rem rgb(17 43 58 / .16), 0 .75rem 2rem rgb(17 43 58 / .12);
    cursor: pointer;
}

.ec-chat-widget [data-floating-native-wrapper] > .ec-chat-widget__toggle {
    translate: 0 var(--ec-chat-anchor-shift, 0px);
}

.ec-chat-widget__badge {
    box-sizing: border-box;
    position: absolute;
    right: -.25rem;
    top: -.2rem;
    display: grid;
    place-items: center;
    min-width: 1.3rem;
    height: 1.3rem;
    padding: 0 .2rem;
    border: 2px solid white;
    border-radius: 1rem;
    background: #bd1936;
    color: white;
    font: 700 .63rem/1 system-ui, sans-serif;
    pointer-events: none;
}
.ec-chat-widget__badge[hidden] { display: none; }
.ec-chat-widget__status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.ec-chat-widget__toggle:focus-visible {
    outline: 2px solid var(--ec-chat-accent, #135c77);
    outline-offset: 3px;
}
.ec-chat-widget__glyph { display: grid; place-items: center; }
.ec-chat-widget__glyph svg { max-width: 100%; max-height: 100%; }

.ec-chat-widget__cross {
    display: none;
    position: relative;
    width: 1.35rem;
    height: 1.35rem;
}

.ec-chat-widget__cross::before,
.ec-chat-widget__cross::after {
    content: "";
    position: absolute;
    inset: calc(50% - 1px) 0 auto;
    height: 2px;
    background: currentColor;
    transform: rotate(45deg);
}

.ec-chat-widget__cross::after { transform: rotate(-45deg); }
.ec-chat-widget__toggle[aria-expanded="true"] svg { display: none; }
.ec-chat-widget__toggle[aria-expanded="true"] .ec-chat-widget__glyph { display: none; }
.ec-chat-widget__toggle[aria-expanded="true"] .ec-chat-widget__cross { display: block; }

.ec-chat-widget__panel {
    position: absolute;
    inset: auto 0 calc(100% + .7rem) auto;
    box-sizing: border-box;
    width: min(25rem, calc(var(--ec-chat-right-edge, 100vw - 1rem) - max(1rem, env(safe-area-inset-left), var(--ec-chat-left-offset, 0px))));
    height: clamp(0px, calc(100vh - 6.2rem - var(--ec-chat-obstruction-offset, 0px)), 35rem);
    height: clamp(0px, calc(100dvh - 6.2rem - max(env(safe-area-inset-bottom), var(--ec-chat-obstruction-offset, 0px))), 35rem);
    overflow: hidden;
    border: 1px solid color-mix(in srgb, currentColor 11%, transparent);
    border-radius: var(--ec-chat-radius, 24px);
    background: var(--ec-chat-surface, #fff);
    box-shadow: 0 .3rem .75rem rgb(17 43 58 / .07), 0 1.1rem 3.6rem rgb(17 43 58 / .19);
}

.ec-chat-widget__panel[hidden] { display: none; }

.ec-chat-widget__panel[data-native-anchor] {
    position: fixed;
    inset: var(--ec-chat-panel-y) auto auto var(--ec-chat-panel-x);
    width: var(--ec-chat-panel-width);
    height: var(--ec-chat-panel-height);
}

.ec-chat-widget__panel iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: var(--ec-chat-surface, #fff);
}

.ec-chat-widget__loading {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: var(--ec-chat-surface, #fff);
    color: var(--ec-chat-text, #172c3d);
    font: 600 .875rem/1.4 system-ui, sans-serif;
    pointer-events: none;
}

.ec-chat-widget__loading[hidden] { display: none; }

.ec-chat-frame {
    margin: 0;
    background: var(--ec-chat-surface, #fff);
    font: var(--ec-chat-size, 16px)/1.45 var(--ec-chat-font, system-ui, sans-serif);
}

.ec-chat-frame .ec-chat-window {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 0;
    --chat-surface: var(--ec-chat-surface, #fff);
    --chat-text: var(--ec-chat-text, #172c3d);
    --chat-muted: color-mix(in srgb, var(--chat-text) 73%, var(--chat-surface));
    --chat-quiet: color-mix(in srgb, var(--chat-action) 3%, var(--chat-surface));
    --chat-own: var(--ec-chat-visitor, #e6f3fa);
    --chat-action: var(--ec-chat-accent, #135c77);
    --chat-line: color-mix(in srgb, var(--chat-text) 13%, var(--chat-surface));
}

.ec-chat-frame--window .ec-chat-window {
    height: 100vh;
    height: 100dvh;
}

.ec-chat-window__header {
    position: relative;
    isolation: isolate;
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    gap: .75rem;
    padding: 1rem;
    border-bottom: 1px solid var(--chat-line);
    background: linear-gradient(120deg, var(--ec-chat-header-start) 14%, var(--ec-chat-header-end));
    color: var(--ec-chat-header-text);
}
.ec-chat-window--visitor .ec-chat-window__header {
    box-sizing: border-box;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    min-height: 8.8rem;
    padding: 1rem 1.15rem;
    background-image: linear-gradient(148deg, var(--ec-chat-header-end), var(--ec-chat-header-start) 78%);
}
.ec-chat-window--visitor .ec-chat-window__controls { grid-column: 2; grid-row: 1; }
.ec-chat-window--visitor .ec-chat-window__heading { grid-column: 1 / -1; }
.ec-chat-window--visitor .ec-chat-window__heading h1,
.ec-chat-window--visitor .ec-chat-window__heading h3 { font-size: 1.26em; }
.ec-chat-window__header[data-chat-header-mode="solid"] { background: var(--ec-chat-header-start); }
.ec-chat-window__cover { display: none; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; }
.ec-chat-window__header[data-chat-header-mode="cover"] .ec-chat-window__cover[src] { display: block; }
.ec-chat-window__header[data-chat-header-mode="cover"]:has(.ec-chat-window__cover[src])::before {
    content: ""; position: absolute; inset: 0; z-index: -1;
    background: linear-gradient(90deg, color-mix(in srgb, var(--ec-chat-header-start) 93%, transparent), color-mix(in srgb, var(--ec-chat-header-end) 42%, transparent));
}

.ec-chat-window__heading { flex: 1; min-width: 0; }
.ec-chat-window__heading h1,
.ec-chat-window__heading h3 {
    margin: 0;
    font-size: 1.04em;
    font-weight: 730;
    letter-spacing: -.025em;
    overflow-wrap: anywhere;
}
.ec-chat-window__heading p { margin: .2rem 0 0; color: inherit; font-size: .81em; overflow-wrap: anywhere; }
.ec-chat-window__controls { display: flex; gap: .35rem; }

.ec-chat-window__mark,
.ec-chat-window__control,
.ec-chat-window__empty > span,
.ec-chat-window .ec-chat__thread-initial {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 50%;
}

.ec-chat-window__mark {
    width: 2.65rem;
    height: 2.65rem;
    background: var(--ec-chat-header-icon-bg);
    color: var(--ec-chat-header-icon-fg);
    box-shadow: 0 .2rem .65rem color-mix(in srgb, var(--chat-action) 24%, transparent);
}
.ec-chat-window__mark svg { width: 1.3rem; height: 1.3rem; }
.ec-chat-window__custom-icon { width: 1.35rem; height: 1.35rem; background: currentColor; mask-size: contain; mask-repeat: no-repeat; mask-position: center; }
.ec-chat-window__control {
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid var(--chat-line);
    background: color-mix(in srgb, var(--chat-surface) 82%, transparent);
    color: var(--chat-text);
    text-decoration: none;
    cursor: pointer;
}
.ec-chat-window__control:hover { border-color: var(--chat-line); background: var(--chat-surface); }
.ec-chat-window__control[hidden] { display: none; }
.ec-chat-window__history a:focus-visible,
.ec-chat-window__control:focus-visible { outline: 2px solid var(--chat-action); outline-offset: 2px; }

.ec-chat-window .ec-chat__panel {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    border: 0;
    border-radius: 0;
    background: var(--chat-quiet);
}
.ec-chat-window .ec-chat__history { align-items: center; gap: .25rem; padding: .4rem .95rem .15rem; }
.ec-chat-window__refresh { margin-inline-start: auto; width: 1.8rem; height: 1.8rem; }
.ec-chat-window .ec-chat__log { flex: 1; min-height: 0; max-height: none; padding: .55rem .85rem .85rem; }

.ec-chat-window__empty {
    display: grid;
    place-items: center;
    gap: .5rem;
    margin: auto;
    padding: .8rem 1.1rem;
    text-align: center;
}
.ec-chat-window__empty > span {
    width: 3.6rem;
    height: 3.6rem;
    margin-bottom: .32rem;
    color: var(--chat-action);
    background: color-mix(in srgb, var(--chat-action) 10%, var(--chat-surface));
}
.ec-chat-window__empty strong { letter-spacing: -.02em; }
.ec-chat-window__empty p { max-width: 15rem; margin: 0; color: var(--chat-muted); font-size: .84em; text-wrap: pretty; }

.ec-chat-window .ec-chat__message {
    border-color: color-mix(in srgb, var(--chat-line) 59%, transparent);
    border-radius: calc(var(--ec-chat-radius, 16px) * .8);
    border-end-start-radius: .28rem;
    padding: .48rem .7rem;
    box-shadow: 0 .12rem .35rem rgb(17 43 58 / .04);
}
.ec-chat-window .ec-chat__message--own {
    border-end-start-radius: calc(var(--ec-chat-radius, 16px) * .8);
    border-end-end-radius: .28rem;
}
.ec-chat-window .ec-chat__message:not(.ec-chat__message--own) { background: var(--ec-chat-team, #fff); }
.ec-chat-window .ec-chat__message div { font-size: .72em; }
.ec-chat-window .ec-chat__message p { margin: .16rem 0 0; font-size: .9em; }

.ec-chat-window .ec-chat__composer {
    flex: 0 0 auto;
    gap: .42rem;
    padding: .7rem .95rem .8rem;
    border-top: 1px solid var(--chat-line);
    background: var(--chat-surface);
}
.ec-chat-window .ec-chat__composer label { font-size: .78em; }
.ec-chat-window .ec-chat__composer input { height: 2rem; padding: .2rem .55rem; font-size: .8em; }
.ec-chat-window .ec-chat__message-input {
    display: flex;
    align-items: flex-end;
    gap: .38rem;
    padding: .25rem .3rem .25rem .5rem;
    border: 1px solid var(--chat-line);
    border-radius: max(.7rem, var(--ec-chat-radius, 16px));
    background: var(--chat-quiet);
}
.ec-chat-window .ec-chat__message-input label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
.ec-chat-window .ec-chat__composer textarea {
    min-width: 0;
    min-height: 2.25rem;
    max-height: 7rem;
    padding: .38rem .28rem;
    border: 0;
    background: transparent;
    font-size: .87em;
    line-height: 1.3;
    resize: vertical;
}
.ec-chat-window .ec-chat__composer button {
    display: grid;
    place-items: center;
    flex: 0 0 2.2rem;
    height: 2.2rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: var(--ec-chat-action-text, #fff);
}
.ec-chat-window .ec-chat__composer button:hover { filter: brightness(.93); }
.ec-chat-window .ec-chat__message-input:focus-within {
    border-color: var(--chat-action);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--chat-action) 16%, transparent);
}
.ec-chat-window .ec-chat__message-input textarea:focus-visible { outline: none; }

.ec-chat-window__queue { flex: 1; overflow: auto; padding: .4rem .7rem .65rem; }
.ec-chat-window .ec-chat__threads { margin: 0; padding: 0; border: 0; list-style: none; }
.ec-chat-window .ec-chat__empty { margin: .65rem .3rem; font-size: .9em; }
.ec-chat-window .ec-chat__threads a {
    min-height: 3.55rem;
    padding: .52rem .38rem;
    border-radius: .55rem;
    color: var(--chat-text);
    font-size: .84em;
    text-decoration: none;
}
.ec-chat-window .ec-chat__threads a:hover { background: var(--chat-quiet); }
.ec-chat-window .ec-chat__thread-person { display: flex; align-items: center; gap: .55rem; }
.ec-chat-window .ec-chat__thread-initial {
    width: 2rem;
    height: 2rem;
    color: var(--chat-action);
    background: color-mix(in srgb, var(--chat-action) 12%, var(--chat-surface));
    font-weight: 700;
}
.ec-chat-window .ec-chat__state {
    flex: 0 0 auto;
    border-radius: 99px;
    padding: .22rem .4rem;
    color: var(--chat-muted);
    background: var(--chat-quiet);
    font-size: .74em;
}
.ec-chat-window .ec-chat__state[data-chat-status="waiting"] {
    color: var(--chat-text);
    background: color-mix(in srgb, var(--chat-action) 13%, var(--chat-surface));
    font-weight: 650;
}

.ec-chat-window__dialog {
    box-sizing: border-box;
    width: min(calc(100% - 1.65rem), 20rem);
    padding: 1.2rem;
    border: 1px solid var(--chat-line);
    border-radius: var(--ec-chat-radius, 16px);
    background: var(--chat-surface);
    color: var(--chat-text);
    box-shadow: 0 1rem 2.5rem rgb(0 0 0 / .2);
}
.ec-chat-window__dialog::backdrop { background: rgb(8 19 36 / .52); }
.ec-chat-window__dialog-icon {
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    background: color-mix(in srgb, var(--chat-action) 11%, var(--chat-surface));
    color: var(--chat-action);
}
.ec-chat-window__dialog h2 { margin: .7rem 0 .35rem; font-size: 1.13em; letter-spacing: -.025em; }
.ec-chat-window__dialog p { margin: 0 0 1rem; color: var(--chat-muted); font-size: .86em; }
.ec-chat-window__dialog p.ec-chat__error { color: var(--chat-error); }
.ec-chat-window__dialog-actions { display: grid; gap: .4rem; }
.ec-chat-window__dialog-actions button {
    min-height: 2.55rem;
    padding: .4rem .7rem;
    border: 1px solid var(--chat-line);
    border-radius: .7rem;
    background: var(--chat-quiet);
    color: var(--chat-text);
    font: inherit;
    font-size: .84em;
    font-weight: 680;
    cursor: pointer;
}
.ec-chat-window__dialog-actions button[type="submit"] { background: var(--chat-action); color: var(--ec-chat-action-text); }
.ec-chat-window__dialog-actions button:disabled { opacity: .55; cursor: wait; }
.ec-chat-window .ec-chat__photo-tools { margin-block: -.2rem -.28rem; }
.ec-chat-window .ec-chat__composer { max-height: 70%; overflow-y: auto; }

@media (max-height: 420px) {
    .ec-chat-window--visitor .ec-chat-window__header { min-height: 0; padding-block: .55rem; gap: .35rem; }
    .ec-chat-window--visitor .ec-chat-window__mark { width: 2rem; height: 2rem; }
    .ec-chat-window--visitor .ec-chat-window__heading h1 { font-size: 1.03em; }
}

@media (pointer: coarse) {
    .ec-chat-window .ec-chat__composer input,
    .ec-chat-window .ec-chat__composer textarea { font-size: max(16px, .87em); }
    .ec-chat-window__controls .ec-chat-window__control { width: 2.75rem; height: 2.75rem; }
}
