#avatarAssistantRoot[hidden] {
    display: none !important;
}

#avatarAssistantRoot .avatar-widget {
    --face-width: 288px;
    --face-height: 320px;
    --avatar-bg-image: url("/avatar/assets/widget/card_background.jpg");
    --avatar-bg-brightness: 0.72;
    --avatar-bg-dim: 0.28;
    --avatar-bg-position: center 42%;
    --avatar-chrome-bg: var(--sidebar-wash);
    --avatar-chrome-surface: #e5dfd4;
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1995;
    pointer-events: auto;
    font-family: var(--font-sans);
}

#avatarAssistantRoot .avatar-widget.is-collapsed {
    right: 28px;
}

#avatarAssistantRoot .avatar-widget.is-collapsed .avatar-widget__card {
    display: none;
}

#avatarAssistantRoot .avatar-widget__fab {
    display: none;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 1px solid var(--sidebar-line);
    border-radius: 50%;
    background: var(--avatar-chrome-bg);
    box-shadow: var(--shadow-modal);
    cursor: pointer;
    font-size: 1.35rem;
    line-height: 1;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

#avatarAssistantRoot .avatar-widget__fab:not([hidden]) {
    display: flex;
}

#avatarAssistantRoot .avatar-widget__fab:hover {
    transform: scale(1.05);
    border-color: var(--accent);
    box-shadow: 0 10px 28px rgba(13, 92, 99, 0.15);
}

#avatarAssistantRoot .avatar-widget__card {
    position: relative;
    display: flex;
    flex-direction: column;
    width: var(--face-width, 288px);
    max-width: calc(100vw - 40px);
    overflow: hidden;
    border-radius: var(--radius);
    border: 1px solid var(--sidebar-line);
    background: var(--avatar-chrome-bg);
    box-shadow: var(--shadow-modal);
}

#avatarAssistantRoot .avatar-widget__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--sidebar-line);
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--avatar-chrome-bg) 100%);
}

#avatarAssistantRoot .avatar-widget__title {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    font-weight: 400;
    color: var(--sidebar-ink);
    letter-spacing: 0.01em;
}

#avatarAssistantRoot .avatar-widget__minimize {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--sidebar-line);
    border-radius: var(--radius-sm);
    background: var(--avatar-chrome-surface);
    color: var(--text-secondary);
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

#avatarAssistantRoot .avatar-widget__minimize:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

#avatarAssistantRoot .avatar-widget__card-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#avatarAssistantRoot .avatar-widget__face {
    position: relative;
    width: 100%;
    height: var(--face-height, 320px);
    border: none;
    padding: 0;
    margin: 0;
    background-color: #3d4544;
    overflow: hidden;
    flex-shrink: 0;
    isolation: isolate;
    border-bottom: 1px solid var(--border);
}

#avatarAssistantRoot .avatar-widget__face::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background-image: var(--avatar-bg-image);
    background-size: cover;
    background-position: var(--avatar-bg-position, center);
    background-repeat: no-repeat;
    filter: brightness(var(--avatar-bg-brightness, 0.82)) saturate(0.95) contrast(1);
    pointer-events: none;
}

#avatarAssistantRoot .avatar-widget__face::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background: linear-gradient(
        180deg,
        rgba(30, 28, 25, 0.08) 0%,
        rgba(22, 20, 18, var(--avatar-bg-dim, 0.28)) 100%
    );
    pointer-events: none;
}

#avatarAssistantRoot .avatar-widget__face canvas {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: block;
}

#avatarAssistantRoot .avatar-widget__face img {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center 18%;
    filter: drop-shadow(0 6px 14px rgba(30, 28, 25, 0.2));
}

#avatarAssistantRoot .avatar-widget__face.mode-3d canvas {
    background: transparent;
    cursor: grab;
}

#avatarAssistantRoot .avatar-widget__face canvas:active {
    cursor: grabbing;
}

#avatarAssistantRoot .avatar-widget__face.avatar-speaking img {
    animation: avatar-assistant-speak-2d 0.32s ease-in-out infinite alternate;
}

#avatarAssistantRoot .avatar-widget__face:not(.mode-3d) {
    animation: avatar-assistant-idle-2d 4s ease-in-out infinite;
}

#avatarAssistantRoot .avatar-widget__panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px 12px;
    background: var(--avatar-chrome-bg);
    border-top: 1px solid var(--sidebar-line);
}

#avatarAssistantRoot .chat-log {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 160px;
    overflow-y: auto;
    padding: 2px 2px 6px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

#avatarAssistantRoot .chat-log--collapsed {
    display: none;
}

#avatarAssistantRoot .chat-msg {
    max-width: 92%;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    line-height: 1.4;
    word-break: break-word;
}

#avatarAssistantRoot .chat-msg--user {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 2px;
}

#avatarAssistantRoot .chat-msg--assistant {
    align-self: flex-start;
    background: var(--sidebar-wash);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-bottom-left-radius: 2px;
}

#avatarAssistantRoot .chat-status {
    margin: 0;
    min-height: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.35;
}

#avatarAssistantRoot .chat-form {
    display: flex;
    gap: 6px;
    align-items: stretch;
}

#avatarAssistantRoot .chat-toggle {
    width: 36px;
    flex-shrink: 0;
    border: 1px solid var(--sidebar-line);
    border-radius: var(--radius-sm);
    background: var(--avatar-chrome-surface);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.65rem;
    line-height: 1;
    transition: transform 0.2s ease, color 0.15s ease, border-color 0.15s ease;
}

#avatarAssistantRoot .chat-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-soft);
}

#avatarAssistantRoot .chat-toggle[aria-expanded="true"] {
    transform: rotate(180deg);
}

#avatarAssistantRoot .chat-form input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--sidebar-line);
    background: var(--avatar-chrome-surface);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-sans);
}

#avatarAssistantRoot .chat-form input::placeholder {
    color: var(--text-muted);
}

#avatarAssistantRoot .chat-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

#avatarAssistantRoot .chat-form button[type="submit"] {
    width: 40px;
    flex-shrink: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.15s ease;
}

#avatarAssistantRoot .chat-form button[type="submit"]:hover:not(:disabled) {
    background: var(--accent-hover);
}

#avatarAssistantRoot .chat-form button:disabled {
    opacity: 0.5;
    cursor: wait;
}

@keyframes avatar-assistant-speak-2d {
    from {
        transform: scale(1) translateY(0);
    }
    to {
        transform: scale(1.03) translateY(-3px);
    }
}

@keyframes avatar-assistant-idle-2d {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-4px);
    }
}
