.llqc-companion {
    position: fixed;
    left: calc(100vw - 184px);
    top: calc(100vh - 246px);
    z-index: 490;
    width: 160px;
    height: 218px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    will-change: left, top;
    transition: opacity 180ms ease;
}

.llqc-companion__mascot {
    position: absolute;
    inset: auto 4px 22px;
    display: grid;
    place-items: end center;
    width: 152px;
    height: 190px;
    padding: 0;
    border: 0;
    border-radius: 38px;
    background: transparent;
    cursor: grab;
    filter: drop-shadow(0 16px 18px rgba(24, 44, 92, .23));
    transition: filter 180ms ease, transform 120ms ease;
}

.llqc-companion__mascot:hover {
    filter: drop-shadow(0 20px 24px rgba(15, 104, 177, .34));
}

.llqc-companion__mascot:active,
.llqc-companion.is-dragging .llqc-companion__mascot {
    cursor: grabbing;
    transform: scale(.975);
}

.llqc-companion__motion {
    position: relative;
    display: block;
    width: 142px;
    height: 184px;
    transform-origin: 50% 82%;
    isolation: isolate;
}

.llqc-companion__frame {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center bottom;
    opacity: 0;
    pointer-events: none;
    transition: opacity 210ms cubic-bezier(.22, 1, .36, 1), filter 160ms ease;
    will-change: opacity;
}

.llqc-companion__frame--active {
    z-index: 2;
    opacity: 1;
}

.llqc-companion__frame--buffer {
    z-index: 1;
}

.llqc-companion__eyes {
    --llqc-eye-x: 0px;
    --llqc-eye-y: 0px;
    position: absolute;
    inset: 0;
    z-index: 4;
    opacity: 0;
    pointer-events: none;
    transition: opacity 90ms ease;
}

.llqc-companion[data-emotion="curious"][data-frame="center"]:not(.is-frame-transitioning) .llqc-companion__eyes {
    opacity: 1;
}

.llqc-companion__eye {
    position: absolute;
    top: 26.3%;
    width: 13.2px;
    height: 13.2px;
    overflow: hidden;
    border-radius: 50%;
    background: #27dcf7;
    box-shadow: 0 0 4px rgba(35, 221, 250, .78);
    transform: translate(-50%, -50%);
}

.llqc-companion__eye--left { left: 36.8%; }
.llqc-companion__eye--right { left: 56.5%; }

.llqc-companion__pupil {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 7.4px;
    height: 7.4px;
    border-radius: 50%;
    background: #04182d;
    transform: translate(calc(-50% + var(--llqc-eye-x)), calc(-50% + var(--llqc-eye-y)));
    will-change: transform;
}

.llqc-companion__pupil::after {
    content: "";
    position: absolute;
    left: 1px;
    top: .6px;
    width: 2.5px;
    height: 2.5px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 1px rgba(255, 255, 255, .9);
}

.llqc-companion__controls {
    position: absolute;
    right: 1px;
    bottom: 0;
    z-index: 4;
    display: flex;
    align-items: center;
}

.llqc-companion__voice {
    padding: 7px 10px;
    border: 1px solid rgba(18, 80, 166, .16);
    border-radius: 999px;
    background: rgba(255, 255, 255, .97);
    box-shadow: 0 6px 16px rgba(25, 47, 91, .14);
    color: #19345e;
    font: 700 10px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    cursor: pointer;
    white-space: nowrap;
}

.llqc-companion__voice[aria-pressed="true"] {
    border-color: #13aee6;
    background: #e8f9ff;
    color: #075f86;
    box-shadow: 0 0 0 3px rgba(25, 200, 255, .12), 0 7px 18px rgba(25, 47, 91, .16);
}

.llqc-companion__emotion {
    position: absolute;
    left: 7px;
    bottom: 1px;
    z-index: 4;
    padding: 7px 9px;
    border-radius: 999px;
    background: rgba(12, 35, 73, .88);
    color: #fff;
    font: 750 9px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: .02em;
    pointer-events: none;
}

.llqc-companion__speech {
    position: absolute;
    right: 104px;
    bottom: 160px;
    z-index: 5;
    width: max-content;
    max-width: min(286px, calc(100vw - 48px));
    min-width: 184px;
    padding: 12px 15px;
    border: 1px solid rgba(18, 80, 166, .12);
    border-radius: 17px 17px 4px 17px;
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 14px 34px rgba(25, 47, 91, .18);
    color: #19345e;
    font: 650 13px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    text-align: left;
    cursor: pointer;
    opacity: 0;
    transform: translateY(8px) scale(.98);
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
}

.llqc-companion__speech::after {
    content: "";
    position: absolute;
    right: -8px;
    bottom: 10px;
    width: 16px;
    height: 16px;
    border-top: 1px solid rgba(18, 80, 166, .12);
    border-right: 1px solid rgba(18, 80, 166, .12);
    background: #fff;
    transform: rotate(45deg);
}

.llqc-companion.is-speaking .llqc-companion__speech {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.llqc-companion.is-speech-right .llqc-companion__speech {
    right: auto;
    left: 104px;
    border-radius: 17px 17px 17px 4px;
}

.llqc-companion.is-speech-right .llqc-companion__speech::after {
    right: auto;
    left: -8px;
    border: 0;
    border-bottom: 1px solid rgba(18, 80, 166, .12);
    border-left: 1px solid rgba(18, 80, 166, .12);
}

.llqc-companion[data-emotion="happy"] .llqc-companion__motion img,
.llqc-companion[data-emotion="wave"] .llqc-companion__motion img {
    filter: saturate(1.1) brightness(1.03);
}

.llqc-companion[data-emotion="thinking"] .llqc-companion__motion img {
    filter: saturate(.94);
}

.llqc-companion[data-emotion="surprised"] .llqc-companion__motion img {
    filter: brightness(1.08);
}

.llqc-companion[data-emotion="sleepy"] .llqc-companion__motion img {
    filter: saturate(.78) brightness(.94);
}

.llqc-companion[data-emotion="worried"] .llqc-companion__motion img {
    filter: saturate(.78);
}

.llqc-companion.is-voice-playing .llqc-companion__voice {
    animation: llqc-voice-pulse .8s ease-in-out infinite alternate;
}

.llqc-companion.is-voice-playing .llqc-companion__motion {
    filter: drop-shadow(0 0 12px rgba(25, 200, 255, .5));
}

.llqc-companion__mascot:focus-visible,
.llqc-companion__speech:focus-visible,
.llqc-companion__voice:focus-visible {
    outline: 3px solid #19c8ff;
    outline-offset: 4px;
}

body.ll-assistant-open .llqc-companion {
    opacity: .28;
    pointer-events: none;
}

html[data-ll-theme="dark"] .llqc-companion__speech,
html[data-ll-theme="dark"] .llqc-companion__voice {
    border-color: rgba(124, 218, 255, .24);
    background: rgba(10, 25, 55, .97);
    color: #ecf8ff;
}

html[data-ll-theme="dark"] .llqc-companion__speech::after {
    border-color: rgba(124, 218, 255, .24);
    background: #0a1937;
}

@keyframes llqc-voice-pulse {
    from { box-shadow: 0 0 0 2px rgba(25, 200, 255, .12); }
    to { box-shadow: 0 0 0 7px rgba(25, 200, 255, .22); }
}

@media (max-width: 767px) {
    .llqc-companion { width: 120px; height: 170px; left: calc(100vw - 134px); top: calc(100vh - 186px); }
    .llqc-companion__mascot { width: 114px; height: 146px; bottom: 20px; }
    .llqc-companion__motion { width: 104px; height: 140px; }
    .llqc-companion__eye { width: 9.8px; height: 9.8px; }
    .llqc-companion__pupil { width: 5.5px; height: 5.5px; }
    .llqc-companion__pupil::after { left: .7px; top: .4px; width: 1.9px; height: 1.9px; }
    .llqc-companion__speech { right: 82px; bottom: 121px; min-width: 158px; max-width: min(242px, calc(100vw - 36px)); padding: 10px 12px; font-size: 12px; }
    .llqc-companion.is-speech-right .llqc-companion__speech { left: 80px; }
    .llqc-companion__emotion { font-size: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    .llqc-companion,
    .llqc-companion * { animation: none !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
    .llqc-companion__pupil { transform: translate(-50%, -50%) !important; }
}
