#kd-live-chat-root {
    --kd-chat-accent: #fbbf24;
    --kd-chat-bg: #0f172a;
    --kd-chat-panel: #1e293b;
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 99990;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

#kd-live-chat-launcher {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: none;
    border-radius: 9999px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #0f172a;
    font-weight: 700;
    font-size: 0.875rem;
    padding: 0.75rem 1.1rem;
    box-shadow: 0 10px 30px rgba(251, 191, 36, 0.35);
    cursor: pointer;
}

#kd-live-chat-launcher .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}

#kd-live-chat-panel {
    display: none;
    flex-direction: column;
    width: min(360px, calc(100vw - 2rem));
    height: min(520px, calc(100vh - 6rem));
    margin-bottom: 0.75rem;
    border-radius: 1rem;
    overflow: hidden;
    background: var(--kd-chat-panel);
    color: #e2e8f0;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

#kd-live-chat-panel.open { display: flex; }

.kd-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    background: rgba(15, 23, 42, 0.85);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.kd-chat-header strong { font-size: 0.95rem; }
.kd-chat-header small { display: block; color: #94a3b8; font-size: 0.75rem; }

.kd-chat-close {
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 1.25rem;
    cursor: pointer;
}

#kd-chat-preform {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem;
}

#kd-chat-thread {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch;
}

#kd-chat-preform form {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

#kd-chat-preform label {
    font-size: 0.75rem;
    color: #94a3b8;
}

#kd-chat-preform input {
    width: 100%;
    border-radius: 0.65rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: #0f172a;
    color: #f8fafc;
    padding: 0.55rem 0.75rem;
    font-size: 0.875rem;
}

.kd-hp-field {
    position: absolute;
    left: -9999px;
    opacity: 0;
    height: 0;
    overflow: hidden;
}

.kd-chat-btn {
    border: none;
    border-radius: 0.75rem;
    background: var(--kd-chat-accent);
    color: #0f172a;
    font-weight: 700;
    padding: 0.65rem 1rem;
    cursor: pointer;
}

.kd-chat-btn:disabled { opacity: 0.6; cursor: not-allowed; }

#kd-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    width: 100%;
}

.kd-msg {
    max-width: 88%;
    padding: 0.55rem 0.75rem;
    border-radius: 0.85rem;
    font-size: 0.875rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.kd-msg.in {
    align-self: flex-start;
    background: #334155;
}

.kd-msg.out {
    align-self: flex-end;
    background: #fbbf24;
    color: #0f172a;
}

.kd-msg .meta {
    margin-top: 0.25rem;
    font-size: 0.65rem;
    opacity: 0.7;
}

.kd-msg-typing {
    background: rgba(251, 191, 36, 0.18);
    color: #fde68a;
    border: 1px dashed rgba(251, 191, 36, 0.35);
}

.kd-typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    min-height: 1rem;
}

.kd-typing-dots span {
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background: #fbbf24;
    animation: kd-typing-bounce 1.2s infinite ease-in-out;
}

.kd-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.kd-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes kd-typing-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
    40% { transform: translateY(-3px); opacity: 1; }
}

#kd-chat-restart {
    display: none;
    padding: 0.85rem 1rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

#kd-chat-restart p {
    margin: 0 0 0.65rem;
    font-size: 0.8rem;
    color: #94a3b8;
    line-height: 1.45;
}

#kd-chat-restart .kd-chat-btn {
    width: 100%;
}

#kd-chat-compose {
    display: none;
    padding: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    gap: 0.5rem;
}

#kd-chat-compose.open {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

#kd-chat-input {
    flex: 1;
    resize: none;
    min-height: 42px;
    max-height: 120px;
    border-radius: 0.65rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: #0f172a;
    color: #f8fafc;
    padding: 0.55rem 0.75rem;
    font-size: 0.875rem;
}

@media (max-width: 480px) {
    #kd-live-chat-root {
        right: 0.75rem;
        bottom: 0.75rem;
    }
}
