.kg-assistant-launcher {
    --kg-assistant-z: 9999;
    --kg-assistant-bg: rgba(255, 255, 255, 0.96);
    --kg-assistant-border: rgba(148, 163, 184, 0.25);
    --kg-assistant-shadow: 0 22px 50px -20px rgba(15, 23, 42, 0.48);
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: var(--kg-assistant-z);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    pointer-events: none;
}

.kg-assistant-launcher * {
    box-sizing: border-box;
}

.kg-install-app-button {
    right: 20px;
    bottom: 94px;
    transition: transform 160ms ease, opacity 160ms ease, background-color 160ms ease;
}

.kg-assistant-launcher.is-open ~ .kg-install-app-button {
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
}

.kg-assistant-bubble {
    pointer-events: auto;
    position: relative;
    width: 58px;
    height: 58px;
    border: 0;
    border-radius: 9999px;
    background: linear-gradient(135deg, #16a34a 0%, #06b6d4 52%, #2563eb 100%);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 16px 30px -14px rgba(14, 116, 144, 0.68), 0 8px 16px -12px rgba(2, 132, 199, 0.64);
    transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease;
}

.kg-assistant-bubble::before {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    border: 2px solid rgba(255, 255, 255, 0.4);
    animation: kg-assistant-pulse 2.2s ease-in-out infinite;
}

.kg-assistant-bubble:hover {
    transform: translateY(-2px) scale(1.03);
    filter: saturate(1.1);
    box-shadow: 0 20px 36px -14px rgba(14, 116, 144, 0.72), 0 14px 22px -18px rgba(30, 64, 175, 0.7);
}

.kg-assistant-bubble:active {
    transform: scale(0.96);
}

.kg-assistant-bubble-icon {
    width: 25px;
    height: 25px;
    stroke: currentColor;
    stroke-width: 1.9;
}

.kg-assistant-panel {
    pointer-events: auto;
    width: min(360px, calc(100vw - 24px));
    height: min(520px, calc(100vh - 92px));
    border-radius: 24px;
    border: 1px solid var(--kg-assistant-border);
    background: var(--kg-assistant-bg);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: var(--kg-assistant-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform-origin: bottom right;
    transform: translateY(12px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: transform 180ms ease, opacity 180ms ease, visibility 180ms ease;
}

.kg-assistant-launcher.is-open .kg-assistant-panel {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

.kg-assistant-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    background: linear-gradient(120deg, rgba(34, 197, 94, 0.12), rgba(56, 189, 248, 0.16));
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
    cursor: grab;
}

.kg-assistant-header-title {
    min-width: 0;
}

.kg-assistant-header-title p {
    margin: 0;
}

.kg-assistant-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
}

.kg-assistant-subtitle {
    margin-top: 2px;
    font-size: 0.74rem;
    color: #64748b;
}

.kg-assistant-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.kg-assistant-icon-btn {
    border: 0;
    background: var(--kg-btn-grad-secondary, linear-gradient(135deg, #ffffff 0%, #e0f2fe 100%));
    color: #0f172a;
    border: 1px solid rgba(186, 230, 253, 0.9);
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 150ms ease, transform 150ms ease;
}

.kg-assistant-icon-btn:hover {
    background: var(--kg-btn-grad-secondary-hover, linear-gradient(135deg, #f8fafc 0%, #bae6fd 100%));
    transform: translateY(-1px);
}

.kg-assistant-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.kg-assistant-messages {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kg-assistant-row {
    display: flex;
}

.kg-assistant-row.user {
    justify-content: flex-end;
}

.kg-assistant-bubble-msg {
    max-width: 88%;
    border-radius: 16px;
    padding: 10px 12px;
    font-size: 0.85rem;
    line-height: 1.45;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.kg-assistant-row.bot .kg-assistant-bubble-msg {
    color: #334155;
    border: 1px solid rgba(148, 163, 184, 0.26);
    background: #f8fafc;
    border-top-left-radius: 6px;
}

.kg-assistant-row.user .kg-assistant-bubble-msg {
    color: #ffffff;
    background: linear-gradient(135deg, #16a34a, #0ea5e9);
    border-top-right-radius: 6px;
}

.kg-assistant-typing {
    margin-left: 12px;
    margin-bottom: 10px;
    display: none;
    align-items: center;
    gap: 4px;
}

.kg-assistant-typing.is-visible {
    display: inline-flex;
}

.kg-assistant-typing span {
    width: 6px;
    height: 6px;
    border-radius: 9999px;
    background: #94a3b8;
    animation: kg-assistant-dot 1.2s ease-in-out infinite;
}

.kg-assistant-typing span:nth-child(2) {
    animation-delay: 0.12s;
}

.kg-assistant-typing span:nth-child(3) {
    animation-delay: 0.24s;
}

.kg-assistant-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 12px 10px;
}

.kg-assistant-chip {
    border: 1px solid rgba(186, 230, 253, 0.9);
    background: var(--kg-btn-grad-secondary, linear-gradient(135deg, #ffffff 0%, #e0f2fe 100%));
    color: #0f172a;
    border-radius: 9999px;
    padding: 5px 10px;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 150ms ease;
}

.kg-assistant-chip:hover {
    border-color: rgba(14, 116, 144, 0.26);
    color: #ffffff;
    background: var(--kg-btn-grad-primary, linear-gradient(135deg, #16a34a 0%, #0ea5e9 100%));
}

.kg-assistant-form {
    border-top: 1px solid rgba(148, 163, 184, 0.23);
    padding: 10px 12px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.9);
}

.kg-assistant-input {
    width: 100%;
    min-height: 40px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.36);
    background: #ffffff;
    padding: 9px 11px;
    font-size: 0.84rem;
    color: #0f172a;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.kg-assistant-input:focus {
    border-color: rgba(16, 185, 129, 0.72);
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.2);
}

.kg-assistant-send {
    flex-shrink: 0;
    min-width: 40px;
    min-height: 40px;
    border-radius: 12px;
    border: 0;
    cursor: pointer;
    color: #ffffff;
    background: var(--kg-btn-grad-primary, linear-gradient(135deg, #16a34a 0%, #0ea5e9 100%));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 150ms ease, opacity 150ms ease, box-shadow 150ms ease;
}

.kg-assistant-send:hover {
    background: var(--kg-btn-grad-primary-hover, linear-gradient(135deg, #15803d 0%, #0284c7 100%));
    transform: translateY(-1px);
    box-shadow: 0 9px 20px -12px rgba(6, 182, 212, 0.75);
}

.kg-assistant-send:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.kg-assistant-error {
    margin: -4px 12px 10px;
    font-size: 0.75rem;
    color: #dc2626;
    display: none;
}

.kg-assistant-error.is-visible {
    display: block;
}

.kg-assistant-bubble:focus-visible,
.kg-assistant-icon-btn:focus-visible,
.kg-assistant-chip:focus-visible,
.kg-assistant-send:focus-visible,
.kg-assistant-input:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.28);
}

@media (max-width: 767px) {
    .kg-assistant-launcher {
        right: 12px;
        bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
        left: 12px;
        align-items: stretch;
    }

    .kg-install-app-button {
        right: 12px;
        bottom: calc(env(safe-area-inset-bottom, 0px) + 82px);
    }

    .kg-assistant-panel {
        width: 100%;
        height: min(72vh, 560px);
        border-radius: 20px;
        transform-origin: bottom center;
    }

    .kg-assistant-launcher .kg-assistant-bubble {
        align-self: flex-end;
    }
}

@media (prefers-color-scheme: dark) {
    .kg-assistant-launcher {
        --kg-assistant-bg: rgba(2, 6, 23, 0.92);
        --kg-assistant-border: rgba(100, 116, 139, 0.35);
    }

    .kg-assistant-title {
        color: #f8fafc;
    }

    .kg-assistant-subtitle {
        color: #cbd5e1;
    }

    .kg-assistant-row.bot .kg-assistant-bubble-msg {
        background: rgba(30, 41, 59, 0.88);
        color: #e2e8f0;
        border-color: rgba(100, 116, 139, 0.45);
    }

    .kg-assistant-chip,
    .kg-assistant-input {
        background: rgba(15, 23, 42, 0.75);
        color: #f1f5f9;
        border-color: rgba(100, 116, 139, 0.45);
    }

    .kg-assistant-form {
        background: rgba(2, 6, 23, 0.55);
    }
}

@media (prefers-reduced-motion: reduce) {
    .kg-assistant-bubble::before,
    .kg-assistant-typing span {
        animation: none;
    }

    .kg-assistant-bubble,
    .kg-assistant-panel,
    .kg-assistant-send,
    .kg-assistant-chip,
    .kg-assistant-icon-btn {
        transition: none;
    }
}

@keyframes kg-assistant-pulse {
    0%, 100% {
        opacity: 0.4;
        transform: scale(1);
    }
    50% {
        opacity: 0.9;
        transform: scale(1.08);
    }
}

@keyframes kg-assistant-dot {
    0%, 80%, 100% {
        transform: scale(0.7);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}
