:root {
    --widget-header-bg: #7A5AF8;
    --widget-surface: #FFFFFF;
    --widget-surface-soft: #FBF9FF;
    --widget-surface-muted: #F4EFFF;
    --widget-background: #F7F5FF;
    --widget-border: #D8D2F6;
    --widget-text: #1E1A2B;
    --widget-muted: #6A5E8E;
    --widget-accent: #6236FF;
    --widget-shadow: 0 24px 60px rgba(98, 54, 255, 0.16);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; padding: 0; font-family: "Plus Jakarta Sans", "Inter", "Segoe UI", sans-serif; background: transparent; overflow: hidden; }
.widget-empty-state { width: 100%; height: 100%; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.25rem; background:
    radial-gradient(circle at top left, rgba(122, 90, 248, 0.16), transparent 34%),
    linear-gradient(180deg, #fcfbff 0%, #f7f5ff 100%); }
.widget-empty-state[hidden] { display: none !important; }
.widget-empty-state__card { width: min(360px, 100%); display: flex; flex-direction: column; align-items: center; gap: .65rem; padding: 1.4rem 1.25rem; text-align: center; border-radius: 1.25rem; border: 1px solid rgba(216, 210, 246, 0.88); background: rgba(255, 255, 255, 0.96); box-shadow: 0 18px 42px rgba(98, 54, 255, 0.1); color: var(--widget-muted); }
.widget-empty-state__card i { font-size: 1.3rem; color: var(--widget-accent); }
.widget-empty-state__card strong { color: var(--widget-text); font-size: 1rem; }
.widget-empty-state__card span { line-height: 1.5; font-size: .92rem; }
.widget-app { width: 100%; height: 100%; min-height: 100vh; padding: 0; background:
    radial-gradient(circle at top left, rgba(122, 90, 248, 0.2), transparent 36%),
    radial-gradient(circle at bottom right, rgba(98, 54, 255, 0.12), transparent 30%),
    linear-gradient(180deg, #fcfbff 0%, #f7f5ff 100%); }
.widget-card { width: 100%; height: 100%; min-height: 100vh; display: flex; flex-direction: column; background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(251, 249, 255, 0.92) 100%);
    backdrop-filter: blur(22px); border: 1px solid rgba(216, 210, 246, 0.8); border-radius: 0; overflow: hidden; }
.widget-header { display: flex; align-items: center; justify-content: space-between; padding: 1.15rem 1.1rem 1rem; background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.14), transparent 42%),
    linear-gradient(135deg, var(--widget-header-bg) 0%, var(--widget-accent) 100%);
    color: #fff; border-bottom: 1px solid rgba(216, 210, 246, 0.72); }
.widget-header__brand { display: flex; align-items: center; gap: .9rem; min-width: 0; }
.widget-header__avatar,
.widget-header__logo { height: 44px; border-radius: 16px; }
.widget-header__avatar { width: 44px; }
.widget-header__logo { width: 76px; }
.widget-header__avatar { display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--widget-header-bg), var(--widget-accent)); color: #fff; box-shadow: 0 8px 20px rgba(98, 54, 255, 0.25); }
.widget-header__logo { object-fit: contain; padding: .28rem .45rem; background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.12), transparent 42%),
    linear-gradient(135deg, var(--widget-header-bg), var(--widget-accent)); border: 1px solid rgba(255, 255, 255, 0.18); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08); }
.widget-header__brand strong { display: block; font-size: 1rem; letter-spacing: -.02em; color: #fff; }
.widget-header__subtitle { margin-top: .18rem; color: rgba(255, 255, 255, 0.78); font-size: .82rem; font-weight: 500; }
.widget-offline { flex: 0 0 auto; margin: .9rem 1rem 0; padding: .85rem 1rem; background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; border-radius: 1rem; font-size: .95rem; }
.widget-conversation { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; background:
    radial-gradient(circle at top, rgba(122, 90, 248, 0.06), transparent 28%),
    linear-gradient(180deg, rgba(247, 245, 255, 0.72) 0%, rgba(255, 255, 255, 0.92) 100%); }
.widget-realtime { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: flex-start; min-width: 0; font-size: .72rem; font-weight: 600; line-height: 1; letter-spacing: .01em; color: var(--widget-muted); }
.widget-realtime[hidden],
.widget-composer__divider[hidden] { display: none !important; }
.widget-realtime__status,
.widget-realtime span,
.widget-realtime button { display: inline-flex; align-items: center; }
.widget-realtime__status { gap: .45rem; min-width: 0; white-space: nowrap; }
.widget-realtime__dot { width: .62rem; height: .62rem; border-radius: 999px; background: #f59e0b; box-shadow: 0 0 0 .22rem rgba(245, 158, 11, 0.15); flex: 0 0 auto; }
.widget-realtime--live .widget-realtime__dot { background: #22c55e; box-shadow: 0 0 0 .22rem rgba(34, 197, 94, 0.16); }
.widget-realtime--offline .widget-realtime__dot { background: #ef4444; box-shadow: 0 0 0 .22rem rgba(239, 68, 68, 0.14); }
.widget-realtime button { width: 1.45rem; height: 1.45rem; justify-content: center; border: 0; border-radius: 999px; background: rgba(122, 90, 248, 0.1); color: var(--widget-accent); font: inherit; padding: 0; cursor: pointer; }
.widget-realtime button:hover { background: rgba(122, 90, 248, 0.16); }
.widget-messages { flex: 1 1 auto; min-height: 0; padding: 1.2rem 1rem .85rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1.1rem; }
.widget-message-row { display: flex; gap: .75rem; align-items: flex-end; }
.widget-message-row--user { justify-content: flex-end; }
.widget-message-avatar { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: linear-gradient(135deg, var(--widget-header-bg), var(--widget-accent)); color: #fff; flex-shrink: 0; box-shadow: 0 8px 18px rgba(98, 54, 255, 0.18); overflow: hidden; }
.widget-message-avatar--logo { background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.12), transparent 42%),
    linear-gradient(135deg, var(--widget-header-bg), var(--widget-accent)); border: 1px solid rgba(216, 210, 246, 0.42); box-shadow: 0 8px 18px rgba(98, 54, 255, 0.12); }
.widget-message-avatar__image { width: 100%; height: 100%; object-fit: contain; padding: .22rem; background: transparent; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.12)); }
.widget-ai-mark { font-size: .75rem; font-weight: 800; letter-spacing: .05em; }
.widget-message-content { display: flex; flex-direction: column; gap: .3rem; max-width: min(84%, 420px); }
.widget-message-meta { padding-left: .15rem; font-size: .75rem; color: #6f62a0; font-weight: 700; letter-spacing: .02em; }
.widget-bubble { padding: .95rem 1rem; border-radius: 1.2rem; line-height: 1.55; font-size: .95rem; box-shadow: 0 10px 24px rgba(98, 54, 255, 0.06); }
.widget-bubble--agent { background: rgba(255, 255, 255, 0.96); color: var(--widget-text); border: 1px solid rgba(216, 210, 246, 0.72); border-top-left-radius: .45rem; }
.widget-bubble--user { background: linear-gradient(135deg, var(--widget-header-bg), var(--widget-accent)); color: #fff; border-bottom-right-radius: .45rem; }
.widget-interactive-message { margin-bottom: .85rem; color: var(--widget-text); }
.widget-carousel { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 78%); gap: .85rem; overflow-x: auto; padding-bottom: .2rem; scroll-snap-type: x proximity; }
.widget-carousel-card { display: flex; flex-direction: column; gap: .7rem; padding: .8rem; border: 1px solid rgba(216, 210, 246, 0.88); border-radius: 1rem; background: rgba(251, 249, 255, 0.92); scroll-snap-align: start; }
.widget-carousel-card__image { width: 100%; height: 120px; object-fit: contain; border-radius: .85rem; background: rgba(216, 210, 246, 0.16); cursor: zoom-in; }
.widget-bubble img,
.widget-bubble picture img { display: block; width: auto; max-width: 100%; max-height: 220px; height: auto; margin-top: .35rem; margin-bottom: .35rem; border-radius: .85rem; object-fit: contain; background: rgba(216, 210, 246, 0.14); }
.widget-bubble a img { margin-top: 0; margin-bottom: 0; }
.widget-bubble video,
.widget-bubble iframe { display: block; width: 100%; max-width: 100%; border: 0; border-radius: .85rem; overflow: hidden; }
.widget-carousel-card__title { font-size: .95rem; line-height: 1.3; }
.widget-carousel-card__description { margin: 0; color: var(--widget-muted); font-size: .88rem; line-height: 1.45; }
.widget-carousel-card__actions { display: flex; flex-direction: column; gap: .55rem; }
.widget-carousel-card__button { display: inline-flex; align-items: center; justify-content: center; width: 100%; min-height: 2.4rem; padding: .7rem .9rem; border: 0; border-radius: .85rem; background: linear-gradient(135deg, var(--widget-header-bg), var(--widget-accent)); color: #fff; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
.widget-identification { margin: 0 1rem 1rem; padding: 1rem; border: 1px solid rgba(216, 210, 246, 0.88); border-radius: 1.45rem; display: none; flex-direction: column; gap: .72rem; background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(251, 249, 255, 0.96) 100%);
    box-shadow: var(--widget-shadow); flex-shrink: 0; }
.widget-identification--visible { display: flex; }
.widget-identification__intro { display: flex; align-items: center; gap: .8rem; }
.widget-identification__icon { width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; border-radius: 14px; background: rgba(122, 90, 248, 0.12); color: var(--widget-accent); }
.widget-identification__headings { display: flex; flex-direction: column; gap: .18rem; min-width: 0; }
.widget-identification__eyebrow { color: var(--widget-accent); font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.widget-identification strong { font-size: 1.02rem; line-height: 1.18; }
.widget-identification span { color: var(--widget-muted); font-size: .9rem; line-height: 1.45; }
.widget-identification__fields { display: grid; gap: .7rem; }
.widget-identification input,
.widget-composer textarea { width: 100%; border: 1px solid rgba(216, 210, 246, 0.95); border-radius: 1rem; padding: .9rem 1rem; font: inherit; background: rgba(255, 255, 255, 0.95); }
.widget-identification input:focus,
.widget-composer textarea:focus { outline: none; border-color: rgba(122, 90, 248, 0.85); box-shadow: 0 0 0 4px rgba(122, 90, 248, 0.12); }
.widget-identification button,
.widget-composer button { border: 0; border-radius: 1rem; padding: .9rem 1rem; cursor: pointer; background: linear-gradient(135deg, var(--widget-header-bg), var(--widget-accent)); color: #fff; font: inherit; font-weight: 700; box-shadow: 0 12px 24px rgba(98, 54, 255, 0.18); }
.widget-identification button[disabled],
.widget-composer button[disabled] { opacity: .75; cursor: wait; }
.widget-identification button.is-loading { display: inline-flex; align-items: center; justify-content: center; gap: .65rem; }
.widget-button-spinner { width: 1rem; height: 1rem; border-radius: 999px; border: 2px solid rgba(255, 255, 255, 0.32); border-top-color: #fff; animation: widget-spin .8s linear infinite; }
.widget-composer { flex: 0 0 auto; padding: .75rem 1rem 1rem; border-top: 1px solid rgba(216, 210, 246, 0.72); background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(14px); box-shadow: 0 -10px 24px rgba(98, 54, 255, 0.05); }
.widget-composer__surface { display: flex; flex-direction: column; gap: .7rem; }
.widget-composer textarea { display: block; width: 100%; height: 96px; min-height: 96px; max-height: 96px; padding: .85rem 1rem; border: 1px solid rgba(216, 210, 246, 0.9); border-radius: 1rem; resize: none; overflow-y: auto; overscroll-behavior: contain; line-height: 1.45; color: var(--widget-text); background: #fff; box-shadow: none; }
.widget-composer textarea::placeholder { color: #8b82ad; }
.widget-composer textarea:focus { box-shadow: 0 0 0 4px rgba(122, 90, 248, 0.12); }
.widget-composer__actions { display: block; width: 100%; }
.widget-composer button { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; width: 100%; min-width: 0; height: 40px; padding: 0 1rem; font-size: .88rem; border-radius: .95rem; box-shadow: 0 10px 20px rgba(98, 54, 255, 0.14); }
.widget-composer button[disabled] { opacity: .5; cursor: not-allowed; }
.widget-composer__meta { display: flex; align-items: center; justify-content: center; gap: .65rem; min-height: 1.35rem; color: #8b82ad; flex-wrap: nowrap; }
.widget-composer__divider { width: 1px; align-self: stretch; background: rgba(139, 130, 173, 0.28); }
.widget-composer__signature { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; text-align: center; font-size: .72rem; color: #8b82ad; letter-spacing: .01em; white-space: nowrap; }
.widget-composer__signature strong { color: inherit; font-weight: 800; }
.widget-image-modal[hidden] { display: none !important; }
.widget-image-modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 1.25rem; background: rgba(30, 26, 43, 0.82); z-index: 20; }
.widget-image-modal__close { position: absolute; top: 1rem; right: 1rem; width: 44px; height: 44px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, 0.96); color: var(--widget-text); cursor: pointer; }
.widget-image-modal__preview { max-width: min(92vw, 720px); max-height: min(82vh, 720px); border-radius: 1rem; box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35); background: #fff; }

@keyframes widget-spin {
    to { transform: rotate(360deg); }
}

@media (min-width: 640px) {
    .widget-messages {
        padding-inline: 1.25rem;
    }

    .widget-identification,
    .widget-offline,
    .widget-composer {
        margin-left: 1rem;
        margin-right: 1rem;
    }

    .widget-composer {
        margin-bottom: 0;
        border-radius: 0;
    }
}

@media (max-width: 480px) {
    .widget-header {
        padding: 1rem;
    }

    .widget-header__avatar,
    .widget-header__logo {
        height: 40px;
        border-radius: 14px;
    }

    .widget-header__avatar {
        width: 40px;
    }

    .widget-header__logo {
        width: 68px;
    }

    .widget-messages {
        padding: 1rem .85rem .75rem;
    }

    .widget-identification {
        margin: 0 .85rem .85rem;
        padding: 1rem;
    }

    .widget-identification__intro {
        align-items: flex-start;
    }

    .widget-composer {
        padding: .6rem .75rem .75rem;
    }

    .widget-composer button {
        height: 38px;
        padding-inline: .9rem;
    }
}
