#ss-chatbot {
    --ss-chatbot-accent: #174b63;
    position: fixed;
    right: clamp(12px, 2vw, 24px);
    bottom: max(16px, env(safe-area-inset-bottom));
    z-index: 99990;
    font: inherit;
    font-size: clamp(14px, 1vw, 16px);
    line-height: 1.5;
    color: #18202b;
    text-align: left;
}

#ss-chatbot[data-accessibe="1"] {
    bottom: max(80px, env(safe-area-inset-bottom));
}

#ss-chatbot *, #ss-chatbot *::before, #ss-chatbot *::after {
    box-sizing: border-box;
}

#ss-chatbot [hidden] {
    display: none !important;
}

#ss-chatbot button, #ss-chatbot textarea {
    font: inherit;
    letter-spacing: normal;
}

#ss-chatbot button {
    cursor: pointer;
    text-transform: none;
    border: 0;
    margin: 0;
}

#ss-chatbot button:focus-visible, #ss-chatbot textarea:focus-visible, #ss-chatbot a:focus-visible {
    outline: 3px solid #d98b1c;
    outline-offset: 3px;
}

#ss-chatbot .ss-chatbot-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-left: auto;
    min-height: 48px;
    padding: 12px 24px;
    border-radius: 999px;
    background: var(--ss-chatbot-accent);
    color: #fff;
    box-shadow: 0 4px 20px #0003;
    font-weight: 700;
}

#ss-chatbot .ss-chatbot-toggle-icon {
    display: block;
    width: 1.25em;
    height: 1.25em;
    flex-shrink: 0;
}

#ss-chatbot-panel {
    display: flex;
    flex-direction: column;
    width: min(390px, calc(100vw - 24px));
    height: min(580px, calc(100vh - 100px));
    height: min(580px, calc(100dvh - 100px));
    margin-bottom: 12px;
    overflow: hidden;
    border: 1px solid #d5dce0;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 8px 40px #0003;
}

#ss-chatbot .ss-chatbot-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--ss-chatbot-accent);
    color: #fff;
}

#ss-chatbot h2 {
    margin: 0;
    padding: 0;
    font: inherit;
    font-weight: 700;
    color: inherit;
    flex: 1;
}

#ss-chatbot .ss-chatbot-close {
    width: 44px;
    height: 44px;
    padding: 0;
    background: transparent;
    color: #fff;
    font-size: 28px;
    flex-shrink: 0;
}

#ss-chatbot .ss-chatbot-clear {
    flex-shrink: 0;
    width: 80px;
    min-height: 44px;
    padding: 4px;
    background: transparent;
    color: #fff;
    font-size: 11px;
    line-height: 1.3;
    text-decoration: underline;
}

#ss-chatbot .ss-chatbot-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px;
}

#ss-chatbot .ss-chatbot-message {
    padding: 12px;
    margin: 0 16px 14px 0;
    border-radius: 12px;
    background: #f0f4f6;
    overflow-wrap: anywhere;
}

#ss-chatbot .ss-chatbot-user {
    margin-right: 0;
    margin-left: 24px;
    background: #e5f0f5;
}

#ss-chatbot .ss-chatbot-speaker {
    display: block;
    font-size: 12px;
    font-weight: 700;
}

#ss-chatbot .ss-chatbot-message p {
    margin: 6px 0 0;
    padding: 0;
    font: inherit;
    font-size: 14px;
    color: inherit;
    white-space: pre-wrap;
}

#ss-chatbot .ss-chatbot-sources {
    padding: 0 0 0 22px;
    margin: 10px 0 0;
    font-size: 12px;
}

#ss-chatbot .ss-chatbot-sources a {
    color: #174b63;
    text-decoration: underline;
}

#ss-chatbot .ss-chatbot-message p a {
    color: #174b63;
    text-decoration: underline;
}

#ss-chatbot .ss-chatbot-references {
    margin-top: 12px;
    font-size: 12px;
}

#ss-chatbot .ss-chatbot-references summary {
    cursor: pointer;
    color: #505b64;
}

#ss-chatbot .ss-chatbot-pdf-label {
    margin-left: 6px;
    padding: 1px 4px;
    border: 1px solid #b8c7ce;
    border-radius: 3px;
    font-size: 11px;
}

#ss-chatbot .ss-chatbot-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    margin-top: 12px;
    padding: 9px 16px;
    border-radius: 6px;
    background: var(--ss-chatbot-accent);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
}

#ss-chatbot .ss-chatbot-notice {
    flex-shrink: 0;
    margin: 0;
    padding: 8px 16px;
    font-size: 12px;
    line-height: 1.4;
    color: #505b64;
}

#ss-chatbot .ss-chatbot-form {
    flex-shrink: 0;
    padding: 12px 16px;
    margin: 0;
    border-top: 1px solid #d5dce0;
}

#ss-chatbot label {
    display: block;
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 700;
}

#ss-chatbot .ss-chatbot-input-row {
    display: flex;
    gap: 8px;
}

#ss-chatbot textarea {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    max-height: calc(4.5em + 18px);
    margin: 0;
    padding: 8px 10px;
    border: 1px solid #8a9ba4;
    border-radius: 6px;
    background: #fff;
    color: #18202b;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    overflow-y: auto;
}

#ss-chatbot .ss-chatbot-form button {
    align-self: flex-end;
    padding: 8px 14px;
    min-height: 44px;
    border-radius: 6px;
    background: var(--ss-chatbot-accent);
    color: #fff;
}

#ss-chatbot button:disabled {
    opacity: .6;
    cursor: wait;
}

#ss-chatbot .ss-chatbot-contact-trigger {
    align-self: flex-start;
    padding: 6px 16px;
    background: transparent;
    color: var(--ss-chatbot-accent);
    font-size: 12px;
    text-decoration: underline;
}

#ss-chatbot .ss-chatbot-lead-form {
    padding: 14px;
    margin: 0 0 14px;
    border: 1px solid #d5dce0;
    border-radius: 10px;
    background: #f0f4f6;
}

#ss-chatbot .ss-chatbot-lead-form h3 {
    margin: 0 0 6px;
    color: inherit;
    font: inherit;
    font-weight: 700;
}

#ss-chatbot .ss-chatbot-lead-form p {
    margin: 0 0 12px;
    font-size: 12px;
    line-height: 1.5;
}

#ss-chatbot .ss-chatbot-lead-form input:not([type="checkbox"]) {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    margin: 0 0 12px;
    padding: 8px 10px;
    border: 1px solid #8a9ba4;
    border-radius: 6px;
    background: #fff;
    color: #18202b;
    font: inherit;
    font-size: 14px;
}

#ss-chatbot .ss-chatbot-consent {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
    font-weight: 400;
}

#ss-chatbot .ss-chatbot-consent input {
    flex-shrink: 0;
    margin: 3px 0 0;
    width: 16px;
    height: 16px;
}

#ss-chatbot .ss-chatbot-lead-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

#ss-chatbot .ss-chatbot-lead-actions button {
    min-height: 44px;
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--ss-chatbot-accent);
    color: #fff;
}

#ss-chatbot .ss-chatbot-lead-actions .ss-chatbot-lead-dismiss {
    background: transparent;
    color: var(--ss-chatbot-accent);
}

#ss-chatbot .ss-chatbot-lead-form input:focus-visible {
    outline: 3px solid #d98b1c;
    outline-offset: 3px;
}

#ss-chatbot .ss-chatbot-thinking {
    display: flex;
    align-items: center;
    gap: 5px;
    width: fit-content;
    min-height: 44px;
}

#ss-chatbot .ss-chatbot-thinking span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ss-chatbot-accent);
    animation: ss-chatbot-thinking 1.2s ease-in-out infinite;
}

#ss-chatbot .ss-chatbot-thinking span:nth-child(2) {
    animation-delay: .15s;
}

#ss-chatbot .ss-chatbot-thinking span:nth-child(3) {
    animation-delay: .3s;
}

@keyframes ss-chatbot-thinking {
    0%, 60%, 100% {
        opacity: .35;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

@media (max-width: 767px) {
    #ss-chatbot[data-accessibe="1"]:not(.ss-chatbot-open) {
        left: 50%;
        right: auto;
        bottom: 16px;
        width: max-content;
        max-width: calc(100vw - 24px);
        transform: translateX(-50%);
    }

    #ss-chatbot.ss-chatbot-open {
        z-index: 2147483647;
    }

    #ss-chatbot-panel {
        position: fixed;
        top: calc(var(--ss-chatbot-viewport-top, 0px) + max(8px, env(safe-area-inset-top)));
        left: max(8px, env(safe-area-inset-left));
        right: max(8px, env(safe-area-inset-right));
        width: auto;
        height: calc(100vh - 16px);
        height: calc(var(--ss-chatbot-viewport-height, 100dvh) - max(8px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom)));
        margin: 0;
        border-radius: 12px;
    }

    #ss-chatbot.ss-chatbot-open .ss-chatbot-toggle {
        display: none;
    }

    #ss-chatbot .ss-chatbot-header {
        flex-shrink: 0;
    }

    /* Keep mobile editable text at 16px to avoid Safari focus zoom. */
    #ss-chatbot textarea,
    #ss-chatbot .ss-chatbot-lead-form input:not([type="checkbox"]) {
        font-size: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #ss-chatbot *, #ss-chatbot *::before, #ss-chatbot *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
