.iwai-launcher, .iwai-launcher *, .iwai-dialog, .iwai-dialog * {
    box-sizing: border-box;
}

.iwai-launcher {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 999998;
    font-family: inherit;
}

.iwai-open {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    appearance: none;
    border: 0;
    border-radius: 999px;
    padding: 12px 18px 12px 12px;
    background: #6b15ed;
    color: #fff;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 8px 28px rgba(42, 18, 83, .28);
    transition: transform .18s ease, background-color .18s ease, box-shadow .18s ease;
}

.iwai-open-icon {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    font-size: 18px;
}

.iwai-open:hover,
.iwai-open:focus-visible {
    background: #5710c7;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(42, 18, 83, .34);
}

.iwai-open:focus-visible {
    outline: 3px solid rgba(107, 21, 237, .28);
    outline-offset: 3px;
}

.iwai-dialog[hidden] {
    display: none !important;
}

.iwai-dialog {
    position: fixed;
    left: 20px;
    bottom: 82px;
    z-index: 999999;
    width: min(390px, calc(100vw - 32px));
    height: min(610px, calc(100dvh - 110px));
    font-family: inherit;
}

.iwai-panel {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff !important;
    color: #172033;
    border: 1px solid #e0e4ec;
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(20, 25, 38, .25);
    overscroll-behavior: contain;
}

.iwai-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 15px 16px;
    background: #6b15ed;
    color: #fff;
}

.iwai-header h2 {
    margin: 0;
    color: inherit;
    font-size: 17px;
    line-height: 1.25;
}

.iwai-header span {
    display: block;
    margin-top: 2px;
    color: rgba(255, 255, 255, .78);
    font-size: 12px;
}

.iwai-close {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    border-radius: 8px;
}

.iwai-close:hover,
.iwai-close:focus-visible {
    background: rgba(255, 255, 255, .15);
    color: #fff;
}

.iwai-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px;
    background: #f5f6fa !important;
}

.iwai-message {
    width: fit-content;
    max-width: 88%;
    margin: 0 0 11px;
    padding: 10px 12px;
    border-radius: 13px;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.iwai-message a {
    color: inherit;
    text-decoration: underline;
    font-weight: 600;
}

.iwai-message--assistant {
    background: #fff;
    border: 1px solid #dfe3eb;
    border-bottom-left-radius: 4px;
}

.iwai-message--user {
    margin-left: auto;
    background: #6b15ed;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.iwai-status {
    min-height: 20px;
    padding: 3px 16px;
    background: #f5f6fa;
    color: #626b7a;
    font-size: 11px;
}

.iwai-form {
    display: flex;
    align-items: end;
    gap: 8px;
    padding: 11px 12px;
    border-top: 1px solid #e2e6ed;
    background: #fff;
}

.iwai-form textarea {
    flex: 1;
    min-width: 0;
    min-height: 43px;
    max-height: 105px;
    resize: none;
    border: 1px solid #bdc5d2;
    border-radius: 10px;
    padding: 10px 11px;
    color: #172033;
    background: #fff;
    font: inherit;
    font-size: 14px;
    line-height: 1.35;
}

.iwai-form textarea:focus {
    outline: 3px solid rgba(107, 21, 237, .15);
    border-color: #6b15ed;
}

.iwai-form button {
    min-height: 43px;
    border: 0;
    border-radius: 10px;
    padding: 0 13px;
    background: #6b15ed;
    color: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.iwai-form button:hover,
.iwai-form button:focus-visible {
    background: #5710c7;
    color: #fff;
}

.iwai-form button:disabled,
.iwai-form textarea:disabled {
    opacity: .6;
    cursor: wait;
}

.iwai-note {
    margin: 0;
    padding: 0 12px 9px;
    background: #fff;
    color: #737b88;
    font-size: 10px;
    line-height: 1.35;
    text-align: center;
}

@media (max-width: 600px) {
    .iwai-launcher {
        left: 12px;
        bottom: 12px;
    }

    .iwai-open {
        padding: 10px 15px 10px 10px;
    }

    .iwai-dialog {
        left: 12px;
        bottom: 72px;
        width: calc(100vw - 24px);
        height: min(70dvh, 560px);
        min-height: 390px;
    }

    .iwai-panel {
        border-radius: 16px;
        background: #fff !important;
    }

    .iwai-message {
        max-width: 92%;
    }
}

@media (max-height: 560px) {
    .iwai-dialog {
        top: 8px;
        bottom: 70px;
        height: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .iwai-open {
        transition: none;
    }
}
