.support-chat-root {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 99990;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.support-chat-root[hidden] {
    display: none !important;
}

.support-chat-toggle {
    width: 3.25rem;
    height: 3.25rem;
    border: none;
    border-radius: 9999px;
    background: #faa01d;
    color: #fff;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.support-chat-toggle:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

.support-chat-panel[hidden] {
    display: none !important;
}

.support-chat-panel:not([hidden]) {
    display: flex;
}

.support-chat-panel {
    position: absolute;
    right: 0;
    bottom: calc(3.25rem + 0.75rem);
    width: min(22rem, calc(100vw - 2rem));
    max-height: min(32rem, calc(100dvh - 5.5rem));
    flex-direction: column;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
    overflow: hidden;
}

.support-chat-panel__header {
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem 1rem 0.75rem;
    border-bottom: 1px solid #f3f4f6;
    background: #fff7ed;
    flex-shrink: 0;
}

.support-chat-panel__intro {
    margin: 0.35rem 0 0;
    font-size: 0.8rem;
    line-height: 1.4;
    color: #4b5563;
}

.support-chat-panel__close {
    flex-shrink: 0;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    padding: 0.15rem 0.25rem;
}

.support-chat-panel--in-chat .support-chat-panel__header {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 2;
    padding: 0.5rem;
    border: none;
    background: transparent;
    width: auto;
}

.support-chat-panel--in-chat .support-chat-panel__header-text {
    display: none;
}

.support-chat-panel--in-chat .support-chat-messages {
    padding-top: 2.75rem;
}

.support-chat-guest-form[hidden] {
    display: none !important;
}

.support-chat-guest-form:not([hidden]) {
    display: grid;
}

.support-chat-guest-form {
    gap: 0.75rem;
    padding: 0.75rem 1rem 0;
    flex-shrink: 0;
}

.support-chat-guest-form label {
    display: grid;
    gap: 0.25rem;
    font-size: 0.8rem;
    color: #374151;
}

.support-chat-guest-form input {
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    padding: 0.5rem 0.65rem;
    font: inherit;
}

.support-chat-messages {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.support-chat-panel--prechat .support-chat-messages {
    display: none;
    flex: 0 0 auto;
    padding: 0;
}

.support-chat-message {
    max-width: 90%;
    padding: 0.55rem 0.75rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.support-chat-message--user {
    align-self: flex-end;
    background: #faa01d;
    color: #fff;
}

.support-chat-message--admin {
    align-self: flex-start;
    background: #f3f4f6;
    color: #111827;
}

.support-chat-message--system {
    align-self: center;
    background: #fff7ed;
    color: #6b7280;
    font-size: 0.78rem;
    text-align: center;
}

.support-chat-form {
    display: grid;
    gap: 0.5rem;
    padding: 0.75rem 1rem 1rem;
    border-top: 1px solid #f3f4f6;
    flex-shrink: 0;
    background: #fff;
}

.support-chat-form textarea {
    resize: none;
    min-height: 3.5rem;
    max-height: 6rem;
    border: 1px solid #d1d5db;
    border-radius: 0.75rem;
    padding: 0.65rem 0.75rem;
    font: inherit;
}

.support-chat-send {
    justify-self: end;
    border: none;
    border-radius: 9999px;
    background: #faa01d;
    color: #fff;
    padding: 0.55rem 1rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.support-chat-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.support-chat-error {
    margin: 0 1rem;
    color: #b91c1c;
    font-size: 0.8rem;
}

body.support-chat-body-lock {
    overflow: hidden;
    touch-action: none;
}

@media (max-width: 640px) {
    .support-chat-root {
        right: 0.75rem;
        bottom: 0.75rem;
    }

    .support-chat-root--open {
        inset: 0;
        right: 0;
        bottom: 0;
        left: 0;
        top: 0;
        z-index: 99999;
    }

    .support-chat-root--open .support-chat-toggle {
        position: fixed;
        z-index: 100000;
        right: 0.75rem;
        bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
    }

    .support-chat-root--open .support-chat-panel {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100dvh;
        max-height: none;
        bottom: auto;
        right: auto;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }

    .support-chat-root--open .support-chat-messages {
        padding-top: max(0.75rem, env(safe-area-inset-top, 0px));
    }

    .support-chat-root--open .support-chat-panel--in-chat .support-chat-messages {
        padding-top: max(2.75rem, calc(env(safe-area-inset-top, 0px) + 1.75rem));
    }

    .support-chat-root--open .support-chat-panel__header {
        padding-top: max(1rem, env(safe-area-inset-top, 0px));
    }

    .support-chat-root--open .support-chat-panel--in-chat .support-chat-panel__header {
        padding-top: max(0.5rem, env(safe-area-inset-top, 0px));
    }

    .support-chat-root--open .support-chat-form {
        padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
    }

    .support-chat-root--open .support-chat-send {
        justify-self: stretch;
        width: 100%;
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }

    .support-chat-root--open .support-chat-form textarea {
        min-height: 5rem;
        font-size: 1rem;
    }

    .support-chat-root--open .support-chat-guest-form input {
        font-size: 1rem;
        padding: 0.65rem 0.75rem;
    }

    .support-chat-panel {
        width: calc(100vw - 1.5rem);
    }
}
