.ai-survey-chat {
    --ai-accent: #7457ff;
    --ai-accent-dark: #5035df;
    position: fixed;
    right: max(22px, env(safe-area-inset-right));
    bottom: max(22px, env(safe-area-inset-bottom));
    z-index: 10050;
    font: 15px/1.45 Arial, sans-serif;
}
.ai-survey-chat__launcher {
    display: flex;
    gap: 12px;
    align-items: center;
    min-height: 68px;
    padding: 0 23px 0 19px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #8c6dff 0%, #5d42e8 55%, #3f2fbb 100%);
    color: #fff;
    box-shadow: 0 14px 34px rgba(69, 43, 181, .34), inset 0 1px rgba(255,255,255,.25);
    cursor: pointer;
    font-weight: 700;
    transition: transform .18s ease, box-shadow .18s ease;
}

.ai-survey-chat__launcher-text { display:flex; flex-direction:column; align-items:flex-start; line-height:1.18; text-align:left; }
.ai-survey-chat__launcher-text span:first-child { font-size:15px; }
.ai-survey-chat__launcher-text span:last-child { margin-top:3px; font-size:13px; color:rgba(255,255,255,.82); }

.ai-survey-chat__launcher:hover { transform: translateY(-2px); box-shadow: 0 18px 40px rgba(69,43,181,.42); }
.ai-survey-chat__launcher:focus-visible, .ai-survey-chat button:focus-visible, .ai-survey-chat textarea:focus-visible { outline: 3px solid rgba(116,87,255,.35); outline-offset: 3px; }
.ai-survey-chat__spark {
    display:inline-block;
    font-size:23px;
    line-height:1;
    transform-origin:center;
    animation:aiSurveySparkGlimmer 1.15s ease-out .65s 1 both;
}

.ai-survey-chat__dialog {
    box-sizing: border-box;
    position: absolute;
    right: 0;
    bottom: 68px;
    display: flex;
    width: min(430px, calc(100vw - 28px));
    height: min(650px, calc(100vh - 120px));
    min-width: 330px;
    min-height: 340px;
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    overflow: hidden;
    resize: both;
    flex-direction: column;
    border: 1px solid rgba(74, 58, 150, .14);
    border-radius: 22px;
    background: #f7f7fb;
    color: #20212a;
    box-shadow: 0 24px 70px rgba(31, 24, 70, .28);
}

.ai-survey-chat__dialog.is-floating { position:fixed; right:auto; bottom:auto; }

.ai-survey-chat__dialog[hidden] { display: none; }
.ai-survey-chat__header { display: flex; justify-content: space-between; align-items: center; padding: 18px 18px 16px; background: linear-gradient(135deg,#6650e9,#30247e); color:#fff; cursor:move; touch-action:none; user-select:none; }
.ai-survey-chat__header strong, .ai-survey-chat__header small { display:block; }
.ai-survey-chat__header strong { font-size: 17px; }
.ai-survey-chat__header small { margin-top: 3px; color: rgba(255,255,255,.75); font-size: 12px; }
.ai-survey-chat__header-actions { display:flex; gap:8px; align-items:center; cursor:default; }
.ai-survey-chat__close, .ai-survey-chat__expand, .ai-survey-chat__clear { width:38px; height:38px; padding:0; border:0; border-radius:50%; background:rgba(255,255,255,.13); color:#fff; cursor:pointer; font-size:25px; line-height:1; }
.ai-survey-chat__expand { font-size:22px; }
.ai-survey-chat__clear { width:32px; height:32px; font-size:16px; }
.ai-survey-chat__clear:disabled { cursor:wait; opacity:.5; }
.ai-survey-chat__messages { flex:1; overflow-y:auto; padding:18px; }
.ai-survey-chat__message { max-width: 87%; margin: 0 0 12px; padding: 11px 13px; border-radius: 15px; white-space: pre-wrap; overflow-wrap:anywhere; }
.ai-survey-chat__message.is-assistant { border-bottom-left-radius:5px; background:#fff; box-shadow:0 4px 14px rgba(31,24,70,.07); }
.ai-survey-chat__message.is-user { margin-left:auto; border-bottom-right-radius:5px; background:#6650e9; color:#fff; }
.ai-survey-chat__message strong { font-weight:700; }
.ai-survey-chat__message.is-pending { color:#74717f; animation: aiSurveyPulse 1.2s ease-in-out infinite; }
.ai-survey-chat__message.is-error { color:#a31621; background:#fff0f1; }
.ai-survey-chat__suggestions { display:flex; gap:7px; overflow-x:auto; padding:0 15px 10px; }
.ai-survey-chat__suggestions button { flex:0 0 auto; padding:7px 10px; border:1px solid #d9d4f7; border-radius:999px; background:#fff; color:#4b3db0; cursor:pointer; font-size:12px; }
.ai-survey-chat__form { display:flex; gap:8px; align-items:flex-end; padding:12px 14px; border-top:1px solid #e3e1ee; background:#fff; }
.ai-survey-chat__input { box-sizing:border-box; flex:1; max-height:120px; padding:10px 11px; resize:none; border:1px solid #d3cfdf; border-radius:12px; font:14px/1.4 Arial,sans-serif; }
.ai-survey-chat__send { width:42px; height:42px; border:0; border-radius:12px; background:var(--ai-accent); color:#fff; cursor:pointer; font-size:22px; }
.ai-survey-chat__send:disabled { cursor:wait; opacity:.55; }
.ai-survey-chat footer { padding:0 14px 10px; background:#fff; color:#85818f; font-size:11px; text-align:center; }

.ai-survey-chat.is-expanded .ai-survey-chat__dialog {
    position:fixed !important;
    inset:max(18px,env(safe-area-inset-top)) max(18px,env(safe-area-inset-right)) max(18px,env(safe-area-inset-bottom)) max(18px,env(safe-area-inset-left)) !important;
    width:auto !important;
    height:auto !important;
    max-width:none !important;
    max-height:none !important;
    resize:none !important;
}

.ai-survey-chat.is-dragging, .ai-survey-chat.is-dragging * { cursor:grabbing !important; user-select:none !important; }

@keyframes aiSurveyPulse { 50% { opacity:.55; } }
@keyframes aiSurveySparkGlimmer {
    0%, 100% { transform:scale(1) rotate(0); filter:brightness(1); text-shadow:0 0 0 rgba(255,255,255,0); }
    38% { transform:scale(1.32) rotate(12deg); filter:brightness(2); text-shadow:0 0 7px #fff, 0 0 15px rgba(255,244,157,.95); }
    62% { transform:scale(1.12) rotate(-6deg); filter:brightness(1.45); text-shadow:0 0 5px rgba(255,255,255,.85); }
}

@media (prefers-reduced-motion: reduce) {
    .ai-survey-chat__spark { animation:none; }
}

@media (max-width: 600px) {
    .ai-survey-chat { right:max(12px,env(safe-area-inset-right)); bottom:max(12px,env(safe-area-inset-bottom)); }
    .ai-survey-chat__launcher-text { display:none; }
    .ai-survey-chat__launcher { width:56px; min-height:56px; padding:0; justify-content:center; }
    .ai-survey-chat__dialog, .ai-survey-chat__dialog.is-floating { position:fixed; inset:max(10px,env(safe-area-inset-top)) max(10px,env(safe-area-inset-right)) max(78px,calc(env(safe-area-inset-bottom) + 68px)) max(10px,env(safe-area-inset-left)); width:auto !important; height:auto !important; min-width:0; min-height:0; max-width:none; max-height:none; resize:none; }
    .ai-survey-chat.is-expanded .ai-survey-chat__dialog { 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)); }
}
