.vals-chat-root,
.vals-chat-root * {
    box-sizing: border-box;
}

.vals-chat-root {
    --vals-chat-orange: #e97824;
    --vals-chat-orange-dark: #b94f12;
    --vals-chat-ink: #17212b;
    --vals-chat-muted: #66717d;
    --vals-chat-surface: #ffffff;
    --vals-chat-soft: #f4f6f8;
    --vals-chat-border: #dfe4e8;
    position: fixed;
    z-index: 2147482000;
    right: max(18px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    font-family: Montserrat, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--vals-chat-ink);
    line-height: 1.4;
}

.vals-chat-root--left {
    right: auto;
    left: max(18px, env(safe-area-inset-left));
}

.vals-chat-launcher,
.vals-chat-teaser,
.vals-chat-close,
.vals-chat-end,
.vals-chat-send,
.vals-chat-link-button,
.vals-chat-identify-submit {
    appearance: none;
    border: 0;
    font: inherit;
    cursor: pointer;
}

.vals-chat-launcher {
    position: relative;
    display: grid;
    width: 58px;
    height: 58px;
    place-items: center;
    margin-left: auto;
    border-radius: 50%;
    background: var(--vals-chat-orange);
    color: #fff;
    box-shadow: 0 8px 24px rgba(23, 33, 43, .22);
}

.vals-chat-root--left .vals-chat-launcher { margin-left: 0; }
.vals-chat-launcher svg { width: 28px; height: 28px; stroke: currentColor; stroke-width: 1.8; }
.vals-chat-launcher:hover { background: var(--vals-chat-orange-dark); }

.vals-chat-launcher:focus-visible,
.vals-chat-teaser:focus-visible,
.vals-chat-close:focus-visible,
.vals-chat-end:focus-visible,
.vals-chat-send:focus-visible,
.vals-chat-link-button:focus-visible,
.vals-chat-identify-submit:focus-visible,
.vals-chat-input:focus-visible,
.vals-chat-identify-input:focus-visible,
.vals-chat-messages:focus-visible {
    outline: 3px solid rgba(233, 120, 36, .4);
    outline-offset: 3px;
}


.vals-chat-teaser {
    position: absolute;
    right: 70px;
    bottom: 7px;
    width: max-content;
    max-width: min(245px, calc(100vw - 110px));
    padding: 10px 13px;
    border-radius: 14px;
    background: #198754;
    color: #fff;
    box-shadow: 0 8px 24px rgba(23, 33, 43, .2);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
    text-align: left;
}
.vals-chat-root--left .vals-chat-teaser { right: auto; left: 70px; }
.vals-chat-teaser::after {
    content: '';
    position: absolute;
    right: -7px;
    bottom: 13px;
    width: 14px;
    height: 14px;
    background: #198754;
    transform: rotate(45deg);
}
.vals-chat-root--left .vals-chat-teaser::after { right: auto; left: -7px; }
.vals-chat-teaser:hover { filter: brightness(.95); }
.vals-chat-teaser[hidden] { display: none !important; }

.vals-chat-badge {
    position: absolute;
    top: -5px;
    right: -3px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border: 2px solid #fff;
    border-radius: 999px;
    background: #b42318;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

.vals-chat-panel {
    display: flex;
    width: min(370px, calc(100vw - 32px));
    height: min(590px, calc(100vh - 100px));
    min-height: 420px;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 12px;
    border: 1px solid var(--vals-chat-border);
    border-radius: 18px;
    background: var(--vals-chat-surface);
    box-shadow: 0 18px 50px rgba(23, 33, 43, .22);
}

.vals-chat-panel[hidden], .vals-chat-identify[hidden], .vals-chat-status[hidden], .vals-chat-after-hours[hidden], .vals-chat-badge[hidden] { display: none !important; }

.vals-chat-header {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 16px;
    border-bottom: 3px solid var(--vals-chat-orange);
    background: #1f2c38;
    color: #fff;
}
.vals-chat-brand { font-size: 15px; font-weight: 700; }
.vals-chat-header-actions { display: flex; align-items: center; gap: 7px; }
.vals-chat-end { min-height: 32px; padding: 5px 8px; border-radius: 8px; background: transparent; color: rgba(255,255,255,.88); font-size: 11px; font-weight: 600; }
.vals-chat-end:hover { background: rgba(255,255,255,.1); color: #fff; }
.vals-chat-subtitle { margin-top: 2px; color: rgba(255,255,255,.78); font-size: 12px; }
.vals-chat-close { width: 36px; height: 36px; border-radius: 10px; background: rgba(255,255,255,.1); color: #fff; font-size: 24px; line-height: 1; }
.vals-chat-close:hover { background: rgba(255,255,255,.18); }

.vals-chat-status {
    flex: 0 0 auto;
    padding: 8px 14px;
    border-bottom: 1px solid var(--vals-chat-border);
    background: #fff8f2;
    color: #6d391d;
    font-size: 12px;
}

.vals-chat-after-hours {
    flex: 0 0 auto;
    padding: 10px 14px;
    border-bottom: 1px solid var(--vals-chat-border);
    background: #fff8f2;
    color: #6d391d;
    font-size: 12px;
}
.vals-chat-after-hours-message { white-space: pre-line; }

.vals-chat-status-message { white-space: pre-line; }
.vals-chat-emergency-link { display: inline-block; margin-top: 5px; color: #8a3512; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.vals-chat-emergency-link:focus-visible { outline: 3px solid rgba(233, 120, 36, .4); outline-offset: 3px; }

.vals-chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 13px 8px;
    background: var(--vals-chat-soft);
}
.vals-chat-welcome { margin: 0 0 14px; padding: 10px 12px; border-radius: 12px; background: #fff; color: var(--vals-chat-muted); font-size: 13px; box-shadow: 0 1px 2px rgba(23,33,43,.06); }
.vals-chat-message { display: flex; margin: 8px 0; }
.vals-chat-message--visitor { justify-content: flex-end; }
.vals-chat-message--staff { justify-content: flex-start; }
.vals-chat-bubble { max-width: 82%; padding: 9px 11px 7px; border-radius: 14px; background: #fff; box-shadow: 0 1px 2px rgba(23,33,43,.08); }
.vals-chat-message--visitor .vals-chat-bubble { background: #ffe7d4; border-bottom-right-radius: 5px; }
.vals-chat-message--staff .vals-chat-bubble { border-bottom-left-radius: 5px; }
.vals-chat-message-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.vals-chat-time { display: block; margin-top: 3px; color: var(--vals-chat-muted); font-size: 10px; text-align: right; }
.vals-chat-typing-bubble { padding-top: 8px; padding-bottom: 8px; }
.vals-chat-typing-text { color: var(--vals-chat-muted); font-size: 11px; font-style: italic; }

.vals-chat-identify { flex: 0 0 auto; padding: 10px 13px; border-top: 1px solid var(--vals-chat-border); background: #fff; font-size: 12px; }
.vals-chat-identify-prompt { font-weight: 600; }
.vals-chat-identify-actions { display: flex; gap: 12px; margin-top: 5px; }
.vals-chat-link-button { padding: 0; background: transparent; color: var(--vals-chat-orange-dark); font-size: 12px; text-decoration: underline; text-underline-offset: 2px; }
.vals-chat-identify-form { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 8px; }
.vals-chat-identify-input { min-width: 0; height: 34px; padding: 6px 8px; border: 1px solid var(--vals-chat-border); border-radius: 8px; background: #fff; color: var(--vals-chat-ink); font: inherit; font-size: 12px; }
.vals-chat-identify-form .vals-chat-identify-input:first-child { grid-column: 1 / -1; }
.vals-chat-identify-submit { min-height: 34px; padding: 6px 12px; border-radius: 8px; background: #1f2c38; color: #fff; font-size: 12px; font-weight: 600; }
.vals-chat-form-error { grid-column: 1 / -1; color: #b42318; font-size: 11px; }

.vals-chat-composer { display: flex; flex: 0 0 auto; align-items: flex-end; gap: 8px; padding: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--vals-chat-border); background: #fff; }
.vals-chat-input { display: block; width: 100%; max-height: 120px; resize: vertical; min-height: 42px; padding: 9px 10px; border: 1px solid var(--vals-chat-border); border-radius: 11px; background: #fff; color: var(--vals-chat-ink); font: inherit; font-size: 14px; line-height: 1.35; }
.vals-chat-send { flex: 0 0 auto; min-width: 62px; min-height: 42px; padding: 8px 13px; border-radius: 11px; background: var(--vals-chat-orange); color: #fff; font-size: 13px; font-weight: 700; }
.vals-chat-send:hover { background: var(--vals-chat-orange-dark); }
.vals-chat-send:disabled, .vals-chat-identify-submit:disabled { cursor: default; opacity: .55; }
.vals-chat-sr-only { 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; }

@media (max-width: 480px) {
    .vals-chat-root,
    .vals-chat-root--left {
        right: max(10px, env(safe-area-inset-right));
        left: max(10px, env(safe-area-inset-left));
        bottom: max(10px, env(safe-area-inset-bottom));
    }
    .vals-chat-root--keyboard-open,
    .vals-chat-root--keyboard-open.vals-chat-root--left {
        bottom: calc(var(--vals-chat-keyboard-inset, 0px) + 8px);
    }
    .vals-chat-launcher { margin-left: auto; }
    .vals-chat-teaser { max-width: calc(100vw - 105px); }
    .vals-chat-panel {
        width: 100%;
        height: min(82dvh, calc(var(--vals-chat-visual-height, 100dvh) - 78px));
        max-height: calc(var(--vals-chat-visual-height, 100dvh) - 78px);
        min-height: 0;
        margin-bottom: 8px;
        border-radius: 16px;
    }
    .vals-chat-root--keyboard-open .vals-chat-composer { padding-bottom: 10px; }
    .vals-chat-input,
    .vals-chat-identify-input { font-size: 16px; }
    .vals-chat-identify-form { grid-template-columns: 1fr; }
    .vals-chat-identify-form .vals-chat-identify-input:first-child { grid-column: auto; }
    .vals-chat-form-error { grid-column: auto; }
}

@media (max-width: 340px) {
    .vals-chat-root,
    .vals-chat-root--left { right: 6px; left: 6px; bottom: max(6px, env(safe-area-inset-bottom)); }
    .vals-chat-root--keyboard-open,
    .vals-chat-root--keyboard-open.vals-chat-root--left { bottom: calc(var(--vals-chat-keyboard-inset, 0px) + 6px); }
    .vals-chat-panel { height: calc(var(--vals-chat-visual-height, 100dvh) - 72px); max-height: calc(var(--vals-chat-visual-height, 100dvh) - 72px); border-radius: 12px; }
    .vals-chat-header { padding: 12px; }
    .vals-chat-messages { padding-left: 9px; padding-right: 9px; }
}

@media (prefers-reduced-motion: reduce) {
    .vals-chat-root *, .vals-chat-root *::before, .vals-chat-root *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
