.eco-companion {
    --pet-x: 0deg;
    --pet-y: 0deg;
    position: fixed;
    right: clamp(14px, 2.5vw, 38px);
    bottom: clamp(14px, 3vh, 34px);
    z-index: 1200;
    width: 210px;
    display: grid;
    justify-items: center;
    filter: drop-shadow(0 20px 26px rgba(6, 78, 59, .2));
    transform: scale(var(--pet-scale, 1));
    transform-origin: top left;
    transition: opacity .28s ease;
    user-select: none;
    -webkit-user-select: none;
}

.eco-companion-stage {
    position: relative;
    width: 178px;
    height: 236px;
    display: grid;
    place-items: end center;
    cursor: grab;
    touch-action: none;
    isolation: isolate;
    transform: perspective(700px) rotateX(var(--pet-x)) rotateY(var(--pet-y));
    transition: transform .18s ease;
}

.eco-companion-stage::before {
    content: "";
    position: absolute;
    inset: 20% 5% 3%;
    z-index: -2;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 64%, rgba(52, 211, 153, .38), rgba(16, 185, 129, .08) 50%, transparent 72%);
    animation: pet-aura 3.4s ease-in-out infinite;
}

.eco-companion-stage::after {
    content: "";
    position: absolute;
    bottom: 2px;
    width: 112px;
    height: 18px;
    z-index: -1;
    border-radius: 50%;
    background: rgba(6, 78, 59, .19);
    filter: blur(8px);
    animation: pet-shadow 3.4s ease-in-out infinite;
}

.eco-companion-stage img {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    transform-origin: 50% 90%;
    animation: pet-float 3.4s ease-in-out infinite;
}

.eco-companion-bubble {
    position: relative;
    max-width: 190px;
    margin: 0 0 -10px -18px;
    padding: 10px 13px;
    border: 1px solid rgba(16, 185, 129, .24);
    border-radius: 15px 15px 4px 15px;
    background: rgba(255, 255, 255, .94);
    color: #065f46;
    box-shadow: 0 10px 28px rgba(15, 23, 42, .1);
    backdrop-filter: blur(12px);
    font-size: 13px;
    line-height: 1.45;
    cursor: pointer;
    transform-origin: bottom right;
    animation: pet-bubble-in .38s cubic-bezier(.2, .8, .2, 1);
}

.eco-companion-bubble::after {
    content: "";
    position: absolute;
    right: 8px;
    bottom: -7px;
    border: 7px solid transparent;
    border-top-color: rgba(255, 255, 255, .94);
    transform: rotate(-18deg);
}

.eco-companion-toggle {
    position: absolute;
    right: 6px;
    top: 42px;
    z-index: 5;
    width: 28px;
    height: 28px;
    border: 1px solid rgba(255, 255, 255, .75);
    border-radius: 50%;
    background: rgba(6, 95, 70, .82);
    color: white;
    box-shadow: 0 5px 12px rgba(6, 78, 59, .18);
    cursor: pointer;
}

.eco-companion-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 7px;
    padding: 7px 11px;
    border: 1px solid rgba(167, 243, 208, .7);
    border-radius: 999px;
    background: rgba(236, 253, 245, .9);
    color: #065f46;
    font-size: 11px;
    backdrop-filter: blur(10px);
}

.eco-companion-status span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, .14);
}

.eco-companion-status em { color: #64748b; font-style: normal; }
.eco-companion-status strong { font-size: 12px; }

.eco-companion.is-dragging .eco-companion-stage { cursor: grabbing; transition: none; }
.eco-companion.is-dragging .eco-companion-stage img { animation-play-state: paused; }
.eco-companion-tools { display: flex; align-items: center; gap: 5px; margin-top: 6px; padding: 3px 6px; border-radius: 20px; background: rgba(255,255,255,.93); color: #065f46; box-shadow: 0 3px 12px rgba(6,78,59,.1); }
.eco-companion-tools button { width: 25px; height: 25px; border: 0; border-radius: 50%; background: #ecfdf5; color: #065f46; cursor: pointer; font-size: 17px; }
.eco-companion-tools button:hover { background: #a7f3d0; }
.eco-companion-scale { min-width: 38px; text-align: center; font-size: 11px; }
.eco-companion-resize { position: absolute; right: 0; bottom: 39px; width: 28px; height: 28px; border: 1px solid #a7f3d0; border-radius: 50%; background: rgba(236,253,245,.95); color: #047857; cursor: nwse-resize; touch-action: none; }

.eco-companion-orbit {
    position: absolute;
    z-index: 1;
    inset: 24% 3% 9%;
    border: 1px solid rgba(52, 211, 153, .34);
    border-radius: 50%;
    transform: rotate(-18deg);
    animation: pet-orbit 7s linear infinite;
}

.orbit-two { inset: 35% 15% 18%; animation-duration: 5s; animation-direction: reverse; }
.eco-companion-spark { position: absolute; z-index: 3; color: #34d399; text-shadow: 0 0 10px #6ee7b7; animation: pet-spark 2.4s ease-in-out infinite; }
.spark-one { top: 27%; left: 6%; }
.spark-two { top: 49%; right: 4%; animation-delay: -1.1s; font-size: 7px; }

.eco-companion[data-state="thinking"] .eco-companion-stage img { animation: pet-think 1.05s ease-in-out infinite; }
.eco-companion[data-state="thinking"] .eco-companion-orbit { animation-duration: 1.8s; border-color: rgba(14, 165, 233, .42); }
.eco-companion[data-state="thinking"] .eco-companion-status span { background: #0ea5e9; box-shadow: 0 0 0 4px rgba(14, 165, 233, .14); }
.eco-companion[data-state="happy"] .eco-companion-stage img { animation: pet-happy .68s cubic-bezier(.2, .8, .2, 1) 2; }
.eco-companion[data-state="happy"] .eco-companion-spark { color: #fbbf24; }

.eco-companion.is-compact { width: 92px; }
.eco-companion.is-compact .eco-companion-stage { width: 82px; height: 102px; }
.eco-companion.is-compact .eco-companion-bubble,
.eco-companion.is-compact .eco-companion-status,
.eco-companion.is-compact .eco-companion-orbit,
.eco-companion.is-compact .eco-companion-spark,
.eco-companion.is-compact .eco-companion-tools { display: none; }
.eco-companion.is-compact .eco-companion-toggle { top: 0; right: 0; }
.eco-companion.is-compact .eco-companion-resize { bottom: 0; right: 0; width: 25px; height: 25px; }

.welcome-pet {
    position: relative;
    width: 132px;
    height: 152px;
    margin: -24px auto 2px;
    display: grid;
    place-items: end center;
}
.welcome-pet img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; animation: pet-float 3.8s ease-in-out infinite; }
.welcome-pet-glow { position: absolute; inset: 38% 7% 4%; border-radius: 50%; background: radial-gradient(circle, rgba(52,211,153,.34), transparent 70%); filter: blur(8px); }

@keyframes pet-float { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-9px) rotate(1deg); } }
@keyframes pet-aura { 0%,100% { opacity: .58; transform: scale(.94); } 50% { opacity: 1; transform: scale(1.05); } }
@keyframes pet-shadow { 0%,100% { transform: scaleX(.9); opacity: .6; } 50% { transform: scaleX(.72); opacity: .34; } }
@keyframes pet-orbit { to { transform: rotate(342deg); } }
@keyframes pet-spark { 0%,100% { opacity: .25; transform: translateY(5px) scale(.75); } 50% { opacity: 1; transform: translateY(-8px) scale(1.1); } }
@keyframes pet-think { 0%,100% { transform: translateY(-2px) rotate(-2deg); } 50% { transform: translateY(-8px) rotate(3deg); } }
@keyframes pet-happy { 0%,100% { transform: translateY(0) scale(1); } 45% { transform: translateY(-18px) scale(1.035) rotate(-2deg); } }
@keyframes pet-bubble-in { from { opacity: 0; transform: translateY(7px) scale(.94); } }

@media (max-width: 760px) {
    .eco-companion { right: 8px; bottom: 112px; width: 126px; opacity: .96; }
    .eco-companion-stage { width: 112px; height: 144px; }
    .eco-companion-bubble { max-width: 132px; margin-left: -22px; padding: 8px 10px; font-size: 11px; }
    .eco-companion-status { display: none; }
    .eco-companion-toggle { top: 35px; right: -2px; }
}

@media (prefers-reduced-motion: reduce) {
    .eco-companion *, .welcome-pet img { animation: none !important; transition-duration: .01ms !important; }
}
