.livechat-widget {
    position: fixed;
    z-index: 1000;
    right: max(20px, env(safe-area-inset-right));
    bottom: max(20px, env(safe-area-inset-bottom));
    display: flex;
    align-items: flex-end;
    flex-direction: column-reverse;
    gap: 12px;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}

.livechat-launcher {
    display: inline-flex;
    min-height: 54px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 19px;
    border: 0;
    border-radius: 999px;
    color: #fff;
    background: #176b5b;
    box-shadow: 0 8px 26px rgb(16 75 64 / 26%);
    cursor: pointer;
    font: inherit;
    font-size: .92rem;
    font-weight: 700;
    transition: background .2s ease, box-shadow .2s ease, transform .2s ease;
}

.livechat-launcher:hover {
    transform: translateY(-2px);
    background: #104b40;
    box-shadow: 0 10px 30px rgb(16 75 64 / 32%);
}

.livechat-launcher:focus-visible,
.livechat-close:focus-visible,
.livechat-question:focus-visible,
.livechat-back:focus-visible {
    outline: 3px solid #d79262;
    outline-offset: 3px;
}

.livechat-launcher svg {
    width: 23px;
    height: 23px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.livechat-panel[hidden] {
    display: none;
}

.livechat-panel {
    display: flex;
    width: min(370px, calc(100vw - 32px));
    max-height: min(560px, calc(100vh - 112px));
    max-height: min(560px, calc(100dvh - 112px));
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #dce8df;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 16px 48px rgb(24 53 47 / 20%);
    color: #18352f;
}

.livechat-panel-header {
    display: flex;
    min-height: 76px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 18px;
    color: #fff;
    background: #176b5b;
}

.livechat-panel-header > div {
    display: grid;
    gap: 4px;
}

.livechat-panel-header strong {
    font-size: 1rem;
}

.livechat-panel-header small {
    color: rgb(255 255 255 / 78%);
    font-size: .75rem;
}

.livechat-close {
    display: grid;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    place-items: center;
    border: 1px solid rgb(255 255 255 / 35%);
    border-radius: 50%;
    color: #fff;
    background: transparent;
    cursor: pointer;
    font: inherit;
    font-size: 1.45rem;
    line-height: 1;
}

.livechat-messages {
    display: flex;
    min-height: 180px;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    padding: 18px;
}

.livechat-greeting,
.livechat-answer {
    max-width: 92%;
    margin: 0;
    padding: 12px 14px;
    border-radius: 14px 14px 14px 4px;
    background: #f0f5eb;
    color: #344b3e;
    font-size: .86rem;
    line-height: 1.55;
    white-space: pre-line;
}

.livechat-question-list {
    display: grid;
    gap: 8px;
}

.livechat-question {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid #dce8df;
    border-radius: 11px;
    color: #176b5b;
    background: #fff;
    cursor: pointer;
    font: inherit;
    font-size: .82rem;
    line-height: 1.4;
    text-align: left;
    transition: border-color .16s ease, background .16s ease;
}

.livechat-question:hover {
    border-color: #9fc5b2;
    background: #f6faf6;
}

.livechat-question:disabled {
    cursor: wait;
    opacity: .65;
}

.livechat-question-selected {
    align-self: flex-end;
    max-width: 92%;
    margin: 0;
    padding: 10px 13px;
    border-radius: 14px 14px 4px 14px;
    color: #fff;
    background: #176b5b;
    font-size: .84rem;
    line-height: 1.45;
}

.livechat-answer {
    max-width: 100%;
}

.livechat-answer a {
    color: #176b5b;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
    overflow-wrap: anywhere;
}

.livechat-answer a:hover {
    color: #104b40;
}

.livechat-back {
    align-self: flex-start;
    padding: 8px 0;
    border: 0;
    color: #176b5b;
    background: transparent;
    cursor: pointer;
    font: inherit;
    font-size: .82rem;
    font-weight: 700;
}

.livechat-empty,
.livechat-error {
    margin: 0;
    color: #667871;
    font-size: .84rem;
    line-height: 1.5;
}

.livechat-error {
    color: #a93636;
}

@media (max-width: 600px) {
    .livechat-widget {
        right: max(14px, env(safe-area-inset-right));
        bottom: max(14px, env(safe-area-inset-bottom));
        gap: 10px;
    }

    .livechat-launcher {
        min-height: 50px;
        padding: 0 16px;
        font-size: .86rem;
    }

    .livechat-panel {
        width: min(370px, calc(100vw - 28px));
        max-height: min(560px, calc(100dvh - 90px - env(safe-area-inset-bottom)));
    }
}

@media (prefers-reduced-motion: reduce) {
    .livechat-launcher,
    .livechat-question {
        transition: none;
    }
}
