.assistant-pet {
    position: fixed;
    left: 0;
    top: 0;
    width: clamp(108px, 10.8vw, 142px);
    height: clamp(122px, 12.5vw, 166px);
    z-index: calc(var(--z-popover, 1600) + 8);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    cursor: grab;
    pointer-events: auto;
    transform: translate3d(0, 0, 0);
    transition: filter .18s var(--ease, ease), opacity .18s var(--ease, ease);
}

.assistant-pet[hidden] {
    display: none !important;
}

.assistant-pet.is-dragging {
    cursor: grabbing;
    transition: none;
}

.assistant-pet.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.assistant-pet__stage {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: end center;
    overflow: visible;
    pointer-events: none;
}

.assistant-pet__canvas,
.assistant-pet__fallback {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.assistant-pet__canvas {
    display: block;
    opacity: 0;
    transition: opacity .24s var(--ease, ease);
}

.assistant-pet.has-live2d .assistant-pet__canvas {
    opacity: 1;
}

.assistant-pet.has-live2d .assistant-pet__fallback {
    opacity: 0;
    pointer-events: none;
}

.assistant-pet__fallback {
    display: grid;
    place-items: end center;
    opacity: 1;
    transition: opacity .24s var(--ease, ease), transform .24s var(--ease, ease);
}

.assistant-pet__sprite,
.assistant-pet__sprite * {
    box-sizing: border-box;
}

.assistant-pet__sprite {
    position: relative;
    width: min(93%, 126px);
    aspect-ratio: 1;
    margin-bottom: 10px;
    transform-origin: 50% 84%;
    pointer-events: none;
    filter:
        drop-shadow(0 12px 0 rgba(20, 32, 88, .08))
        drop-shadow(0 16px 18px rgba(14, 21, 58, .18));
}

.assistant-pet__sprite-img {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    transform: translateZ(0);
    pointer-events: none;
    transition: filter .18s var(--ease, ease), transform .18s var(--ease, ease);
}

.assistant-pet__glow,
.assistant-pet__screen-pulse,
.assistant-pet__bubble,
.assistant-pet__spark,
.assistant-pet__shadow {
    position: absolute;
    pointer-events: none;
}

.assistant-pet__glow {
    z-index: 1;
    left: 20%;
    top: 18%;
    width: 62%;
    height: 70%;
    border-radius: 44% 54% 48% 54%;
    background:
        radial-gradient(circle at 34% 26%, rgba(107, 156, 255, .46), transparent 32%),
        radial-gradient(circle at 68% 64%, rgba(25, 71, 214, .32), transparent 42%);
    filter: blur(10px);
    opacity: .72;
}

.assistant-pet__screen-pulse {
    z-index: 3;
    border-radius: 4px;
    opacity: .22;
    pointer-events: none;
    background:
        linear-gradient(90deg, transparent, rgba(112, 240, 255, .92), transparent),
        linear-gradient(180deg, rgba(114, 240, 255, .24), transparent);
    mix-blend-mode: screen;
    animation: assistantPetScreenSweep 2.9s ease-in-out infinite;
}

.assistant-pet__screen-pulse--face {
    left: 47%;
    top: 42%;
    width: 29%;
    height: 22%;
}

.assistant-pet__screen-pulse--tablet {
    left: 60%;
    top: 67%;
    width: 23%;
    height: 15%;
    transform: rotate(5deg);
    animation-delay: .42s;
}

.assistant-pet__bubble {
    z-index: 5;
    right: 0;
    top: -2px;
    min-width: 27px;
    height: 27px;
    padding: 0 6px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(105, 150, 204, .35);
    border-radius: 999px;
    background:
        linear-gradient(180deg, rgba(231, 245, 255, .96), rgba(204, 232, 255, .96)),
        #d7edff;
    color: #24436f;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .82),
        0 6px 14px rgba(31, 63, 110, .16);
    transition:
        background .18s var(--ease, ease),
        color .18s var(--ease, ease),
        transform .18s var(--ease, ease),
        box-shadow .18s var(--ease, ease);
}

.assistant-pet__spark {
    z-index: 4;
    width: 6px;
    height: 6px;
    border-radius: 2px;
    background: #72f0ff;
    box-shadow: 0 0 10px rgba(114, 240, 255, .55);
    opacity: 0;
}

.assistant-pet__spark--a {
    left: 20%;
    top: 30%;
}

.assistant-pet__spark--b {
    right: 16%;
    top: 47%;
}

.assistant-pet__spark--c {
    left: 40%;
    bottom: 14%;
}

.assistant-pet__shadow {
    z-index: 0;
    left: 50%;
    bottom: 6px;
    width: 58%;
    height: 10px;
    transform: translateX(-50%);
    border-radius: 50%;
    background: rgba(15, 23, 42, .16);
    filter: blur(3px);
}

.assistant-pet__fallback-label {
    position: absolute;
    left: 50%;
    bottom: -1px;
    z-index: 6;
    transform: translateX(-50%) translateY(8px);
    max-width: 128px;
    padding: 4px 8px;
    border: 1px solid rgba(196, 216, 244, .75);
    border-radius: 999px;
    background: rgba(255, 255, 255, .9);
    color: #466082;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 8px 22px rgba(24, 45, 92, .12);
    transition: opacity .18s var(--ease, ease), transform .18s var(--ease, ease);
}

.assistant-pet:hover .assistant-pet__fallback-label {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.assistant-pet__status {
    position: absolute;
    left: 50%;
    bottom: -9px;
    z-index: 7;
    transform: translateX(-50%) translateY(8px);
    max-width: min(180px, 90vw);
    padding: 6px 10px;
    border: 1px solid rgba(196, 216, 244, .75);
    border-radius: 999px;
    background: rgba(255, 255, 255, .94);
    color: var(--text, #111);
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
    box-shadow: 0 10px 26px rgba(17, 17, 17, .12);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s var(--ease, ease), transform .18s var(--ease, ease);
}

.assistant-pet:hover .assistant-pet__status,
.assistant-pet[data-state="thinking"] .assistant-pet__status,
.assistant-pet[data-state="speaking"] .assistant-pet__status,
.assistant-pet[data-state="drag"] .assistant-pet__status,
.assistant-pet[data-state="error"] .assistant-pet__status,
.assistant-pet[data-state="success"] .assistant-pet__status {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.assistant-pet[data-state="idle"] .assistant-pet__sprite {
    animation: assistantPetTyping 1.15s steps(2, end) infinite;
}

.assistant-pet[data-state="idle"] .assistant-pet__screen-pulse--tablet {
    opacity: .46;
    animation-duration: .82s;
}

.assistant-pet[data-state="hover"] .assistant-pet__sprite {
    animation: assistantPetStandUp .28s var(--ease, ease), assistantPetFloat 2.8s ease-in-out .28s infinite;
}

.assistant-pet[data-state="hover"] .assistant-pet__sprite-img {
    filter: saturate(1.12) brightness(1.04);
}

.assistant-pet[data-state="hover"] .assistant-pet__bubble {
    transform: translateY(-3px) scale(1.05);
}

.assistant-pet[data-state="hover"] .assistant-pet__screen-pulse {
    opacity: .38;
    animation-duration: 1.45s;
}

.assistant-pet[data-state="drag"] .assistant-pet__sprite {
    animation: assistantPetLookAround .72s steps(2, end) infinite;
}

.assistant-pet[data-state="drag"] .assistant-pet__sprite-img {
    transform: scale(1.04);
}

.assistant-pet[data-state="thinking"] .assistant-pet__sprite {
    animation: assistantPetThink 1.05s steps(2, end) infinite;
}

.assistant-pet[data-state="thinking"] .assistant-pet__glow {
    opacity: .95;
    filter: blur(12px) saturate(1.3);
}

.assistant-pet[data-state="thinking"] .assistant-pet__bubble {
    animation: assistantPetBubblePulse .82s ease-in-out infinite;
}

.assistant-pet[data-state="thinking"] .assistant-pet__spark {
    animation: assistantPetSpark .8s ease-in-out infinite;
}

.assistant-pet[data-state="thinking"] .assistant-pet__spark--b {
    animation-delay: .12s;
}

.assistant-pet[data-state="thinking"] .assistant-pet__spark--c {
    animation-delay: .24s;
}

.assistant-pet[data-state="speaking"] .assistant-pet__sprite {
    animation: assistantPetSpeak .54s steps(2, end) infinite;
}

.assistant-pet[data-state="speaking"] .assistant-pet__screen-pulse {
    opacity: .56;
    animation-duration: .72s;
}

.assistant-pet[data-state="speaking"] .assistant-pet__bubble {
    transform: translateY(-2px) scale(1.03);
}

.assistant-pet[data-state="success"] .assistant-pet__sprite {
    animation: assistantPetPop .72s var(--ease, ease);
}

.assistant-pet[data-state="success"] .assistant-pet__bubble {
    transform: translateY(-4px) scale(1.08);
}

.assistant-pet[data-state="success"] .assistant-pet__screen-pulse,
.assistant-pet[data-state="success"] .assistant-pet__spark {
    background: #75ff9f;
    box-shadow: 0 0 10px rgba(52, 199, 89, .65);
}

.assistant-pet[data-state="error"] .assistant-pet__sprite {
    animation: assistantPetShake .38s ease-in-out;
}

.assistant-pet[data-state="error"] .assistant-pet__bubble {
    transform: translateX(1px) scale(1.04);
}

.assistant-pet[data-state="error"] .assistant-pet__screen-pulse,
.assistant-pet[data-state="error"] .assistant-pet__spark {
    background: #ff7b72;
    box-shadow: 0 0 10px rgba(255, 59, 48, .6);
}

.assistant-pet[data-state="sleep"] {
    filter: saturate(.72) opacity(.78);
}

.assistant-pet[data-state="sleep"] .assistant-pet__fallback {
    transform: translateY(12px) scale(.92);
}

.assistant-pet[data-state="sleep"] .assistant-pet__sprite {
    animation: assistantPetSleep 3.6s ease-in-out infinite;
}

.assistant-pet[data-state="sleep"] .assistant-pet__screen-pulse,
.assistant-pet[data-state="sleep"] .assistant-pet__spark {
    opacity: 0;
    animation: none;
}

.assistant-pet[data-state="sleep"] .assistant-pet__bubble {
    transform: translateY(5px) scale(.88);
    opacity: .72;
}

.assistant-pet[data-bubble-tone="conversation"] .assistant-pet__bubble {
    background:
        linear-gradient(180deg, rgba(231, 245, 255, .96), rgba(204, 232, 255, .96)),
        #d7edff;
    color: #24436f;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .82),
        0 6px 14px rgba(31, 63, 110, .16);
}

.assistant-pet[data-bubble-tone="thinking"] .assistant-pet__bubble {
    background: linear-gradient(180deg, #f0f7ff, #cce9ff);
    color: #1d54a6;
    animation: assistantPetBubblePulse .82s ease-in-out infinite;
}

.assistant-pet[data-bubble-tone="speaking"] .assistant-pet__bubble {
    background: linear-gradient(180deg, #e4fbff, #bceeff);
    color: #0c5d9f;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .82),
        0 6px 16px rgba(56, 189, 248, .24);
}

.assistant-pet[data-bubble-tone="success"] .assistant-pet__bubble {
    background: linear-gradient(180deg, #ecfff2, #b9f7c9);
    color: #147a38;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .86),
        0 0 0 3px rgba(52, 199, 89, .16),
        0 8px 18px rgba(52, 199, 89, .28);
}

.assistant-pet[data-bubble-tone="error"] .assistant-pet__bubble {
    background: linear-gradient(180deg, #fff2f1, #ffd5d2);
    color: #b42318;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .82),
        0 0 0 3px rgba(255, 59, 48, .13),
        0 8px 18px rgba(255, 59, 48, .2);
}

.assistant-pet[data-bubble-tone="drag"] .assistant-pet__bubble {
    background: linear-gradient(180deg, #f7f3ff, #ded3ff);
    color: #4a2e91;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .82),
        0 6px 16px rgba(88, 86, 214, .22);
}

.assistant-pet[data-bubble-tone="sleep"] .assistant-pet__bubble {
    background: linear-gradient(180deg, #eef2f7, #d9e2ee);
    color: #5b6472;
}

@keyframes assistantPetScreenSweep {
    0%, 100% { transform: translateX(-10px) scaleX(.58); opacity: .12; }
    45% { transform: translateX(8px) scaleX(1); opacity: .42; }
}

@keyframes assistantPetFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-7px) rotate(-1deg); }
}

@keyframes assistantPetTyping {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(2px) rotate(.6deg); }
}

@keyframes assistantPetStandUp {
    0% { transform: translateY(9px) scale(.94); }
    100% { transform: translateY(0) scale(1); }
}

@keyframes assistantPetDrag {
    0%, 100% { transform: rotate(-2deg) translateY(0); }
    50% { transform: rotate(2deg) translateY(-4px); }
}

@keyframes assistantPetLookAround {
    0%, 100% { transform: translateX(-2px) rotate(-2deg); }
    50% { transform: translateX(2px) rotate(2deg); }
}

@keyframes assistantPetThink {
    0%, 100% { transform: translate(0, 0) rotate(-2deg); }
    50% { transform: translate(2px, -3px) rotate(2deg); }
}

@keyframes assistantPetSpeak {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-3px) scale(1.035); }
}

@keyframes assistantPetPop {
    0% { transform: translateY(0) scale(.92); }
    45% { transform: translateY(-9px) scale(1.1); }
    100% { transform: translateY(0) scale(1); }
}

@keyframes assistantPetShake {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    25% { transform: translateX(-5px) rotate(-3deg); }
    75% { transform: translateX(5px) rotate(3deg); }
}

@keyframes assistantPetBubblePulse {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-3px) scale(1.08); }
}

@keyframes assistantPetSpark {
    0%, 100% { transform: translate3d(0, 0, 0) scale(.7); opacity: 0; }
    45% { transform: translate3d(3px, -8px, 0) scale(1); opacity: .95; }
}

@keyframes assistantPetSleep {
    0%, 100% { transform: translateY(4px) rotate(0deg); }
    50% { transform: translateY(8px) rotate(-1deg); }
}

@media (max-width: 720px) {
    .assistant-pet {
        width: 100px;
        height: 116px;
    }

    .assistant-pet__sprite {
        width: 96px;
        margin-bottom: 5px;
    }

    .assistant-pet__bubble {
        right: -2px;
        top: 2px;
        min-width: 24px;
        height: 24px;
        padding: 0 6px;
        font-size: 11px;
    }

    .assistant-pet__fallback-label,
    .assistant-pet__status {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .assistant-pet,
    .assistant-pet *,
    .assistant-pet *::before,
    .assistant-pet *::after {
        animation: none !important;
        transition: none !important;
    }
}
