:root {
    --bg: #0d0f14;
    --surface: #e7edf0;
    --border: rgba(255, 255, 255, 0.07);
    --accent: #528ac2;
    --text: #3e3e3e;
    --text-muted: #a8aaaf;
    --user-bg: #2b2722;
    --bot-bg: #fcfcfc;
    --radius: 25px;
    --font-body: 'DM Sans', sans-serif;
    --font-display: 'DM Serif Display', serif;
}

/* ── Launcher ── */
#albert-launcher {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 8px 32px rgba(79, 124, 255, 0.35);
    outline: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 9999;
}

#albert-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 40px rgba(79, 124, 255, 0.5);
}

#albert-launcher .icon-chat {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

#albert-launcher.open .icon-chat {
    opacity: 0;
    transform: scale(0.5) rotate(90deg);
    position: absolute;
}

#albert-launcher .icon-chat img {
    user-select: none;
}

#albert-launcher .icon-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    opacity: 0;
    transform: scale(0.5) rotate(-90deg);
    position: absolute;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

#albert-launcher.open .icon-close {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

#albert-launcher.open .icon-close svg path {
    stroke: var(--accent);
}

/* Unread badge */
#albert-unread-badge {
    position: fixed;
    bottom: 76px;
    right: 28px;
    background: #ff4d6d;
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    display: none;
}

/* ── Chat Window ── */
#albert-chat-window {
    position: fixed;
    bottom: 104px;
    right: 28px;
    width: 380px;
    height: 560px;
    max-height: calc(88vh - 60px);
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    box-shadow: 0 7px 17px -4px rgba(0, 0, 0, 0.27);
    transform: translateY(20px) scale(0.97);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}

#albert-chat-window.visible {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

#albert-chat-window *::selection {
    background-color: #000;
    color: #fff;
}

/* Header */
.chat-header {
    padding: 0 20px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 20px;
    flex-shrink: 0;
}

.avatar-wrap {
    position: relative;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: var(--font-display);
    color: #fff;
    font-size: 18px;
    /* filter: brightness(1.05); */
    overflow: hidden;
    flex-shrink: 0;
}

.albert-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    opacity: 0;
    z-index: 0;
    transition: opacity 0.2s ease;
}

.albert-video.active {
    opacity: 1;
    z-index: 1;
}

.header-text h3 {
    color: var(--text);
    font-size: 15px;
    margin: 0;
}

.header-text p {
    font-size: 12px;
    color: #948e87;
    font-weight: 500;
    margin: 2px 0 0;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #52bf74;
    display: inline-block;
    margin-right: 5px;
    animation: pulse-dot 2s infinite;
}

.status-dot.connecting {
    background: #f0a500;
    animation: none;
}

.status-dot.offline {
    background: var(--text-muted);
    animation: none;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* Messages */
#albert-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

#albert-messages::-webkit-scrollbar {
    width: 4px;
}

#albert-messages::-webkit-scrollbar-track {
    background: transparent;
}

#albert-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.msg-row {
    display: flex;
    flex-direction: column;
    animation: msg-in 0.25s ease;
}

@keyframes msg-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg-row.user {
    align-items: flex-end;
}

.msg-row.bot {
    align-items: flex-start;
}

.msg-label {
    display: none;
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 4px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.bubble {
    max-width: 77.5%;
    padding: 11px 15px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}

.msg-row.user .bubble {
    background: var(--user-bg);
    color: var(--surface);
    font-weight: 500;
    border-bottom-right-radius: 4px;
}

.msg-row.bot .bubble {
    background: var(--bot-bg);
    color: var(--text);
    font-weight: 500;
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.msg-row.system .bubble {
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-style: italic;
    border: none;
    padding: 4px 0;
    align-self: center;
}

/* Typing indicator */
.typing-bubble {
    background: var(--bot-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    padding: 13px 16px;
    display: flex;
    gap: 5px;
    align-items: center;
}

.typing-bubble span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typing 1.2s infinite;
}

.typing-bubble span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-bubble span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        opacity: 0.3;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

/* Input */
.chat-input-wrap {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
    background: var(--surface);
}

#albert-msg-input {
    flex: 1;
    background: #fff;
    border: 1px solid #dbdbdb;
    border-radius: 25px;
    min-height: 44px;
    padding: 10px 14px;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 400;
    color: var(--text);
    outline: none;
    resize: none;
    max-height: 100px;
    line-height: 1.5;
    transition: border-color 0.2s;
}

#albert-msg-input::placeholder {
    color: #8d8d8d;
}

#albert-msg-input:focus {
    border-color: rgba(79, 124, 255, 0.4);
}

#albert-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    outline: none;
    transition: opacity 0.2s, transform 0.15s;
}

#albert-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

#albert-send-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* Connecting overlay */
#albert-connecting-overlay {
    position: absolute;
    inset: 0;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    z-index: 10;
    backdrop-filter: blur(4px);
    border-radius: var(--radius);
}

#albert-connecting-overlay p {
    color: var(--text);
    font-size: 13px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.mobile-close {
    flex: 1;
    display: none;
    align-items: center;
    justify-content: flex-end;
}

#albert-mobile-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

#albert-mobile-close svg path {
    stroke: #000;
}

/* Mobile */
@media (max-width: 480px) {
    #albert-chat-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100dvh;
        max-height: 100vh;
        border-radius: 0;
    }

    #albert-launcher.open {
        display: none;
    }

    .mobile-close {
        display: flex;
    }
}