.mira-widget {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 9999;
    font-family: Roboto, Arial, sans-serif;
}

.mira-launcher {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px 10px 10px;
    background: #283949;
    border: 1px solid rgba(243, 145, 0, 0.42);
    border-radius: 18px;
    color: #fff;
    box-shadow: 0 12px 28px rgba(40, 57, 73, 0.24);
    cursor: pointer;
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: opacity .18s ease, transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}

.mira-launcher:hover {
    transform: translateY(-3px);
    border-color: rgba(243, 145, 0, 0.72);
    box-shadow: 0 18px 34px rgba(40, 57, 73, 0.32);
}

.mira-launcher-icon {
    width: 46px;
    height: 46px;
    min-width: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 6px 16px rgba(40, 57, 73, 0.22);
}

.mira-launcher-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.mira-launcher-text {
    line-height: 1.15;
    text-align: left;
}

.mira-launcher-title {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
}

.mira-launcher-subtitle {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    color: rgba(255, 255, 255, .74);
}

.mira-panel {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 420px;
    max-width: calc(100vw - 24px);
    height: min(560px, calc(100vh - 36px));
    max-height: calc(100vh - 36px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    border: 1px solid #dfe7ef;
    border-radius: 10px;
    box-shadow: 0 22px 54px rgba(22, 34, 45, .24);
    opacity: 0;
    pointer-events: none;
    transform: translateY(16px) scale(.98);
    transform-origin: right bottom;
    visibility: hidden;
    transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
}

.mira-widget.open .mira-panel {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
    visibility: visible;
    transition-delay: 0s;
}

.mira-widget.open.closing .mira-panel {
    opacity: 0;
    pointer-events: none;
    transform: translateY(16px) scale(.98);
}

.mira-widget.open .mira-launcher {
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px) scale(.96);
}

.mira-widget.open.closing .mira-launcher {
    opacity: 0;
    pointer-events: none;
}

.mira-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: #283949;
    color: #fff;
}

.mira-header img {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: #fff;
}

.mira-header-main {
    min-width: 0;
    flex: 1;
}

.mira-header-title {
    font-size: 14px;
    font-weight: 700;
}

.mira-header-subtitle {
    font-size: 12px;
    color: rgba(255,255,255,.72);
}

.mira-close {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 6px;
    background: rgba(255,255,255,.12);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.mira-messages {
    flex: 1 1 auto;
    min-height: 180px;
    padding: 14px;
    overflow-y: auto;
    background: #f6f8fb;
}

.mira-message {
    max-width: 88%;
    margin-bottom: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-line;
}

.mira-message.bot {
    background: #fff;
    border: 1px solid #e1e8ef;
    color: #243646;
}

.mira-message.thinking {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #52677a;
}

.mira-thinking-dots {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.mira-thinking-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #f59b00;
    opacity: .35;
    animation: miraThinkingPulse 1s infinite ease-in-out;
}

.mira-thinking-dots span:nth-child(2) {
    animation-delay: .16s;
}

.mira-thinking-dots span:nth-child(3) {
    animation-delay: .32s;
}

@keyframes miraThinkingPulse {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: .35;
    }
    40% {
        transform: translateY(-3px);
        opacity: 1;
    }
}

.mira-message-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #edf1f5;
}

.mira-message-actions .mira-action {
    min-height: 34px;
    padding: 7px 10px;
}

.mira-message.user {
    margin-left: auto;
    background: #f59b00;
    color: #fff;
}

.mira-card {
    max-width: 92%;
    margin: 0 0 10px;
    padding: 10px 11px;
    background: #fff;
    border: 1px solid #dde6ef;
    border-radius: 8px;
    color: #243646;
    box-shadow: 0 2px 8px rgba(22, 34, 45, .05);
}

.mira-card-title {
    font-size: 13px;
    font-weight: 700;
    color: #283949;
}

.mira-card-subtitle,
.mira-card-meta {
    margin-top: 3px;
    font-size: 12px;
    color: #68798a;
}

.mira-card-price {
    margin-top: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #f59b00;
}

.mira-card-link {
    display: inline-block;
    margin-top: 8px;
    padding: 5px 10px;
    border-radius: 5px;
    background: #283949;
    color: #fff;
    font-size: 12px;
    text-decoration: none;
}

.mira-card-link:hover {
    color: #fff;
    text-decoration: none;
    opacity: .9;
}

.mira-quick-replies,
.mira-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    flex: 0 0 auto;
    padding: 10px 14px 12px;
    background: #f6f8fb;
}

.mira-quick-replies {
    max-height: 176px;
    overflow-y: auto;
    border-top: 1px solid #e1e8ef;
}

.mira-quick-replies:empty {
    display: none;
}

.mira-actions:empty {
    display: none;
}

.mira-chip,
.mira-action {
    width: 100%;
    min-height: 36px;
    border: 1px solid #cfd9e3;
    border-radius: 7px;
    background: #fff;
    color: #283949;
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(22, 34, 45, .05);
    transition: background .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease;
    white-space: normal;
}

.mira-chip:hover,
.mira-chip:focus {
    border-color: #f59b00;
    background: #fff8ed;
    color: #1f303f;
    box-shadow: 0 3px 10px rgba(245, 155, 0, .14);
    outline: none;
}

.mira-file-input {
    display: none !important;
}

.mira-upload-action {
    border-color: #f59b00;
    color: #9a6100;
}

.mira-action {
    display: flex;
    align-items: center;
    justify-content: center;
    border-color: #283949;
    background: #283949;
    color: #fff;
    text-decoration: none;
}

.mira-action:hover,
.mira-action:focus {
    background: #1f303f;
    color: #fff;
    text-decoration: none;
    outline: none;
}

.mira-action-whatsapp {
    border-color: #25d366;
    background: #fff;
    color: #138a42;
}

.mira-action-whatsapp:hover,
.mira-action-whatsapp:focus {
    background: #effdf5;
    color: #0f7137;
}

.mira-action-link {
    border-color: #f59b00;
    background: #f59b00;
    color: #fff;
}

.mira-action-link:hover,
.mira-action-link:focus {
    border-color: #dd8c00;
    background: #dd8c00;
    color: #fff;
}

.mira-input-row {
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
    padding: 10px 14px 14px;
    border-top: 1px solid #e1e8ef;
    background: #fff;
}

.mira-input-row input {
    flex: 1;
    min-width: 0;
    height: 44px;
    box-sizing: border-box;
    border: 1px solid #d4dde7;
    border-radius: 7px;
    padding: 0 12px;
    font-size: 13px;
    line-height: 44px;
}

.mira-send {
    flex: 0 0 76px;
    height: 44px;
    box-sizing: border-box;
    border: 0;
    border-radius: 7px;
    background: #283949;
    color: #fff;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    line-height: 44px;
    text-align: center;
}

.mira-send:disabled,
.mira-input-row input:disabled {
    opacity: .68;
    cursor: wait;
}

@media (max-width: 767px) {
    .mira-widget {
        right: max(10px, env(safe-area-inset-right));
        bottom: max(10px, env(safe-area-inset-bottom));
        left: auto;
    }

    .mira-launcher {
        padding: 10px;
        border-radius: 16px;
    }

    .mira-launcher-text {
        display: none;
    }

    .mira-launcher-icon {
        width: 48px;
        height: 48px;
        min-width: 48px;
    }

    .mira-panel {
        position: fixed;
        inset: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
        width: auto;
        height: calc(100vh - 16px);
        max-height: calc(100vh - 16px);
        height: calc(100dvh - max(16px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom)));
        max-height: calc(100dvh - max(16px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom)));
        border-radius: 12px;
    }

    .mira-messages {
        min-height: 0;
        padding: 12px 12px var(--mira-mobile-options-space, 10px);
        scroll-padding-bottom: var(--mira-mobile-options-space, 10px);
    }

    .mira-quick-replies {
        max-height: 22dvh;
        padding: 9px 12px 10px;
        overscroll-behavior: contain;
    }

    .mira-quick-replies,
    .mira-actions {
        grid-template-columns: 1fr;
        padding: 9px 12px 10px;
    }

    .mira-input-row {
        padding: 9px 12px calc(10px + env(safe-area-inset-bottom));
        gap: 7px;
    }

    .mira-input-row input {
        height: 42px;
        line-height: 42px;
        font-size: 16px;
    }

    .mira-send {
        flex-basis: 66px;
        height: 42px;
        line-height: 42px;
        padding: 0 10px;
    }

    .mira-message,
    .mira-card {
        max-width: 94%;
    }
}

@media (max-width: 420px) {
    .mira-panel {
        inset: max(6px, env(safe-area-inset-top)) 0 0 0;
        height: calc(100vh - 6px);
        max-height: calc(100vh - 6px);
        height: calc(100dvh - max(6px, env(safe-area-inset-top)));
        max-height: calc(100dvh - max(6px, env(safe-area-inset-top)));
        border-radius: 10px 10px 0 0;
        border-left: 0;
        border-right: 0;
        border-bottom: 0;
    }

    .mira-header {
        padding: 11px 12px;
    }

    .mira-quick-replies {
        max-height: 20dvh;
    }
}
