.chatw {
    --chatw-main: var(--main-one, #1b9fc6);
    --chatw-text: #2b2b2b;
    --chatw-gray: #767676;
    --chatw-bg: #f3f5f7;
    font-family: inherit;
}
.chatw__btn {
    position: fixed; right: 20px; bottom: 20px; z-index: 9990;
    width: 58px; height: 58px; border: 0; border-radius: 50%;
    background: var(--chatw-main); color: #fff;
    display: grid; place-items: center; cursor: pointer;
    box-shadow: 0 8px 24px rgba(27, 159, 198, .4);
    box-shadow: 0 8px 24px color-mix(in srgb, var(--chatw-main) 40%, transparent);
    transition: transform .25s ease, box-shadow .25s ease;
}
.chatw__btn:hover { transform: translateY(-2px) scale(1.04); }
.chatw__btn:focus-visible { outline: 3px solid rgba(27, 159, 198, .4); outline: 3px solid color-mix(in srgb, var(--chatw-main) 40%, transparent); outline-offset: 3px; }
.chatw__icon { grid-area: 1 / 1; transition: opacity .2s ease, transform .25s ease; }
.chatw__icon--close,
.chatw.is-open .chatw__icon--open { opacity: 0; transform: rotate(-45deg) scale(.6); }
.chatw.is-open .chatw__icon--close { opacity: 1; transform: none; }
.chatw__badge {
    position: absolute; top: 2px; right: 2px;
    min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
    background: #ff3b30; color: #fff; font-size: 12px; font-weight: 700; line-height: 20px;
}
.chatw__badge[hidden] { display: none; }

.chatw__panel {
    position: fixed; right: 20px; bottom: 90px; z-index: 10000; margin: 0;
    width: min(390px, calc(100vw - 40px));
    height: min(600px, calc(100dvh - 110px));
    min-height: min(300px, calc(100dvh - 20px));
    display: flex; flex-direction: column;
    border-radius: 16px; background: #fff; color: var(--chatw-text);
    box-shadow: 0 20px 60px rgba(0, 20, 50, .22), 0 4px 14px rgba(0, 20, 50, .08);
    overflow: hidden; font-size: 14px; line-height: 1.45;
}
.chatw__panel[hidden] { display: none; }
.chatw__head {
    display: flex; align-items: center; gap: 8px;
    padding: 14px 12px 14px 18px; background: var(--chatw-main); color: #fff;
}
.chatw__head > div { flex: 1; min-width: 0; }
.chatw__title { font-weight: 700; font-size: 16px; }
.chatw__sub { font-size: 12px; opacity: .85; display: flex; align-items: center; gap: 6px; }
.chatw__dot { width: 7px; height: 7px; border-radius: 50%; background: #5ee07f; flex: none; }
.chatw__sub.is-off .chatw__dot { background: #ffd166; }
.chatw__end {
    border: 1px solid rgba(255, 255, 255, .5); background: none; color: #fff;
    border-radius: 100px; padding: 5px 11px; font: inherit; font-size: 12px; cursor: pointer; white-space: nowrap;
}
.chatw__end[hidden] { display: none; }
.chatw__x {
    border: 0; background: none; color: #fff; width: 36px; height: 36px; border-radius: 50%;
    display: grid; place-items: center; cursor: pointer;
}
.chatw__x:hover,
.chatw__end:hover { background: rgba(255, 255, 255, .15); }

.chatw__log {
    flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 16px;
    display: flex; flex-direction: column; gap: 8px; background: var(--chatw-bg);
}
.chatw__msg {
    max-width: 85%; padding: 9px 13px; border-radius: 16px;
    white-space: pre-wrap; overflow-wrap: anywhere;
}
.chatw__msg--op { align-self: flex-start; background: #fff; border-bottom-left-radius: 6px; }
.chatw__msg--me { align-self: flex-end; background: var(--chatw-main); color: #fff; border-bottom-right-radius: 6px; }
.chatw__msg--me a { color: #fff; }
.chatw__msg--op a { color: var(--chatw-main); }
.chatw__msg--sys {
    align-self: center; background: none; color: var(--chatw-gray);
    font-size: 12px; text-align: center; max-width: 95%;
}
.chatw__msg.is-pending { opacity: .6; }
.chatw__msg.is-failed { background: #ffe5e3; color: #a1160a; }
.chatw__meta { display: block; font-size: 11px; opacity: .7; margin-top: 3px; }
.chatw__img { display: block; max-width: 100%; max-height: 240px; border-radius: 10px; margin-top: 5px; }
.chatw__file { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; text-decoration: underline; color: inherit; }

.chatw__card {
    align-self: stretch; background: #fff; border-radius: 16px; padding: 14px;
    display: grid; gap: 8px; box-shadow: 0 0 0 1px rgba(0, 20, 50, .06);
}
.chatw__card b { font-size: 15px; }
.chatw__card p { margin: 0; font-size: 13px; color: var(--chatw-gray); }
.chatw__card input,
.chatw__card textarea {
    width: 100%; box-sizing: border-box; border: 1px solid #d9dde3; border-radius: 10px;
    padding: 9px 11px; font: inherit; font-size: 14px; background: #fff; color: var(--chatw-text);
}
.chatw__card button {
    justify-self: start; border: 0; border-radius: 100px; padding: 9px 18px;
    background: var(--chatw-main); color: #fff; font: inherit; font-weight: 600; font-size: 13px; cursor: pointer;
}
.chatw__card button:disabled { opacity: .6; cursor: default; }
.chatw__stars { display: flex; gap: 4px; }
.chatw__card .chatw__stars button { background: none; color: #c9ced6; padding: 2px; font-size: 28px; line-height: 1; }
.chatw__card .chatw__stars button.is-on { color: #ffb800; }

.chatw__form {
    display: flex; align-items: flex-end; gap: 6px; padding: 10px 10px 6px;
    border-top: 1px solid #eceef1; background: #fff; margin: 0;
}
.chatw__hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.chatw__form textarea {
    flex: 1; resize: none; border: 0; outline: none; font: inherit;
    padding: 10px 6px; max-height: 120px; background: none; color: var(--chatw-text); box-shadow: none;
}
.chatw__attach,
.chatw__send {
    position: relative; width: 40px; height: 40px; flex: none;
    display: grid; place-items: center; border-radius: 50%; border: 0; cursor: pointer; margin: 0;
}
.chatw__attach { color: var(--chatw-gray); }
.chatw__attach:hover { background: var(--chatw-bg); }
.chatw__attach input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.chatw__attach:focus-within { outline: 2px solid var(--chatw-main); }
.chatw__send { background: var(--chatw-main); color: #fff; }
.chatw__send:disabled { opacity: .5; cursor: default; }
.chatw__consent { margin: 0; padding: 0 16px 10px; font-size: 11px; color: var(--chatw-gray); background: #fff; }
.chatw__consent a,
.chatw__erase {
    color: inherit; text-decoration: underline; text-underline-offset: 2px;
    background: none; border: 0; padding: 0; font: inherit; cursor: pointer;
}
.chatw__consent[hidden] { display: none; }

/* очікування першої відповіді: склянка наповнюється за вікно відповіді */
.chatw__wait {
    align-self: stretch; display: flex; gap: 14px; align-items: center;
    background: #fff; border-radius: 16px; padding: 12px 14px; box-shadow: 0 0 0 1px rgba(0, 20, 50, .06);
}
.chatw__wait-text b { display: block; font-size: 14px; }
.chatw__wait-text p { margin: 2px 0 0; font-size: 12px; color: var(--chatw-gray); }
.chatw__wait-timer { display: inline-block; margin-top: 4px; font-size: 11px; color: var(--chatw-gray); font-variant-numeric: tabular-nums; }
.chatw__cup { position: relative; flex: none; padding-top: 14px; }
.chatw__glass {
    position: relative; width: 36px; height: 48px;
    border: 2px solid #b9dce8; border-top: 0; border-radius: 0 0 9px 9px;
    clip-path: polygon(0 0, 100% 0, 88% 100%, 12% 100%); background: #f4fafc;
}
.chatw__water {
    position: absolute; left: 0; right: 0; bottom: 0; height: 12%;
    background: linear-gradient(180deg, #5cc3e2, var(--chatw-main)); transition: height 1s linear; overflow: hidden;
}
.chatw__water::before {
    content: ''; position: absolute; left: -50%; top: -5px; width: 200%; height: 10px;
    background: radial-gradient(circle at 10px -2px, transparent 7px, #5cc3e2 8px) 0 0 / 20px 10px repeat-x;
    animation: chatw-wave 2s linear infinite;
}
.chatw__water i {
    position: absolute; bottom: 2px; width: 4px; height: 4px; border-radius: 50%; background: rgba(255, 255, 255, .75);
    animation: chatw-bubble 2.6s ease-in infinite;
}
.chatw__water i:nth-child(1) { left: 25%; }
.chatw__water i:nth-child(2) { left: 55%; animation-delay: .9s; width: 3px; height: 3px; }
.chatw__water i:nth-child(3) { left: 72%; animation-delay: 1.7s; }
.chatw__drop {
    position: absolute; z-index: 1; left: 50%; top: 0; width: 7px; height: 9px; margin-left: -3px;
    background: var(--chatw-main); border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    animation: chatw-drop 1.6s ease-in infinite;
}
.chatw__msg--hint { border: 1px dashed rgba(27, 159, 198, .45); border: 1px dashed color-mix(in srgb, var(--chatw-main) 45%, transparent); }
@keyframes chatw-wave { to { transform: translateX(20px); } }
@keyframes chatw-bubble { 0% { transform: translateY(0); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateY(-40px); opacity: 0; } }
@keyframes chatw-drop { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: 1; } 70% { transform: translateY(40px); opacity: 1; } 100% { transform: translateY(46px); opacity: 0; } }

/* помилка в картці */
.chatw__err { margin: 0; font-size: 12px; color: #c0392b; }
.chatw__err[hidden] { display: none; }
/* відкритий чат ховає вкладку нічного банера, щоб вона не перекривала кнопку надсилання */
html.chatw-open .night-banner-tab { display: none !important; }

/* швидкі питання */
.chatw__chips { display: flex; flex-wrap: wrap; gap: 6px; align-self: flex-start; max-width: 95%; }
.chatw__chip {
    border: 1px solid var(--chatw-main); background: #fff; color: var(--chatw-main);
    border-radius: 100px; padding: 7px 12px; font: inherit; font-size: 13px; cursor: pointer; text-align: left;
}
.chatw__chip:hover { background: var(--chatw-main); color: #fff; }

/* запрошення над кнопкою */
.chatw__teaser {
    position: fixed; right: 20px; bottom: 90px; z-index: 9989;
    width: min(290px, calc(100vw - 40px));
    animation: chatw-in .35s ease both;
}
.chatw__teaser[hidden] { display: none; }
.chatw__teaser-body {
    display: block; width: 100%; text-align: left; cursor: pointer;
    border: 0; border-radius: 16px 16px 4px 16px; padding: 12px 30px 12px 14px;
    background: #fff; color: var(--chatw-text); font: inherit; font-size: 14px; line-height: 1.4;
    box-shadow: 0 10px 30px rgba(0, 20, 50, .18), 0 0 0 1px rgba(0, 20, 50, .05);
}
.chatw__teaser-who { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--chatw-main); margin-bottom: 3px; }
.chatw__teaser-x {
    position: absolute; top: 4px; right: 4px; z-index: 1; width: 26px; height: 26px;
    border: 0; background: none; color: var(--chatw-gray); font-size: 20px; line-height: 1; cursor: pointer; border-radius: 50%;
}
.chatw__teaser-x:hover { background: var(--chatw-bg); }
.chatw.has-teaser .chatw__btn { animation: chatw-pulse 2.4s ease-out 2; }
@keyframes chatw-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes chatw-pulse {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--chatw-main) 50%, transparent); }
    70% { box-shadow: 0 0 0 16px color-mix(in srgb, var(--chatw-main) 0%, transparent); }
    100% { box-shadow: 0 8px 24px color-mix(in srgb, var(--chatw-main) 40%, transparent); }
}

/* телефон: панель на весь екран */
@media (max-width: 640px) {
    .chatw__btn { right: 14px; bottom: 14px; width: 54px; height: 54px; }
    .chatw__teaser { right: 14px; bottom: 78px; width: min(270px, calc(100vw - 28px)); }
    .chatw__teaser-body { font-size: 13px; }
    .chatw__panel { inset: 0; width: 100%; height: 100dvh; min-height: 0; border-radius: 0; }
    .chatw.is-open .chatw__btn { display: none; }
    .chatw__form textarea { font-size: 16px; } /* iOS не збільшує сторінку при фокусі */
    html.chatw-open, html.chatw-open body { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) {
    .chatw__btn, .chatw__icon { transition: none; }
    .chatw__teaser, .chatw.has-teaser .chatw__btn, .chatw__water::before, .chatw__water i, .chatw__drop { animation: none; }
}

/* пропозиція сповіщати про відповідь */
.chatw__push p { color: #1b1b1f; }
.chatw__push-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chatw__card .chatw__push-no { background: none; color: #6b6b76; padding-left: 6px; padding-right: 6px; }
