.art-pet {
    position: fixed;
    right: max(22px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 68;
    width: 128px;
    height: 138px;
    font-family: inherit;
    pointer-events: none;
    transition: width 0.2s ease, height 0.2s ease, transform 1.15s linear;
}

.art-pet.is-roaming {
    transform: translateX(var(--art-pet-roam-distance, -76px));
}

.art-pet.is-dragging {
    transition: none;
}

.art-pet-character {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 120px;
    height: 130px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: grab;
    pointer-events: auto;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    filter: drop-shadow(0 10px 12px rgba(36, 31, 61, 0.18));
    transform: scale(var(--art-pet-scale, 1));
    transform-origin: 100% 100%;
    transition: filter 0.2s ease, transform 0.2s ease;
}

.art-pet.is-dragging .art-pet-character {
    cursor: grabbing;
    filter: drop-shadow(0 16px 18px rgba(36, 31, 61, 0.28));
    transform: scale(var(--art-pet-scale, 1));
}

.art-pet-character:hover {
    transform: translateY(-3px) scale(var(--art-pet-scale, 1));
    filter: drop-shadow(0 14px 16px rgba(36, 31, 61, 0.24));
}

.art-pet-character:focus-visible {
    outline: 3px solid rgba(139, 124, 246, 0.35);
    outline-offset: 2px;
    border-radius: 24px;
}

.art-pet-sprite {
    display: block;
    width: 120px;
    height: 130px;
    background-image: url('/assets/pet/rocket.webp');
    background-repeat: no-repeat;
    background-size: 800% 900%;
    background-position: 0 0;
    image-rendering: pixelated;
    transform-origin: 50% 100%;
}

.art-pet-bubble {
    position: absolute;
    right: var(--art-pet-bubble-right, 92px);
    bottom: var(--art-pet-bubble-bottom, 108px);
    width: max-content;
    max-width: min(240px, calc(100vw - 180px));
    padding: 9px 12px;
    border: 1px solid rgba(139, 124, 246, 0.18);
    border-radius: 14px 14px 4px 14px;
    background: rgba(255, 255, 255, 0.96);
    color: #3b3554;
    box-shadow: 0 12px 32px rgba(36, 31, 61, 0.14);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.55;
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px) scale(0.96);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.art-pet-bubble.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.art-pet-panel {
    position: absolute;
    right: 10px;
    bottom: var(--art-pet-panel-bottom, 128px);
    width: min(326px, calc(100vw - 32px));
    overflow: hidden;
    border: 1px solid rgba(166, 149, 196, 0.22);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 24px 70px rgba(36, 31, 61, 0.2);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    pointer-events: auto;
    transform-origin: 86% 100%;
    animation: artPetPanelIn 0.22s ease-out;
}

.art-pet.aligns-panel-left .art-pet-panel {
    right: auto;
    left: 0;
    transform-origin: 14% 100%;
}

.art-pet.opens-panel-below .art-pet-panel {
    top: var(--art-pet-panel-top, 150px);
    bottom: auto;
    transform-origin: 86% 0;
}

.art-pet.aligns-panel-left.opens-panel-below .art-pet-panel {
    transform-origin: 14% 0;
}

.art-pet.aligns-panel-left .art-pet-bubble {
    right: auto;
    left: calc(100% - 24px);
    border-radius: 14px 14px 14px 4px;
}

.art-pet.opens-panel-below .art-pet-bubble {
    top: calc(100% - 24px);
    bottom: auto;
}

.art-pet-panel[hidden],
.art-pet-result[hidden],
.art-pet-actions[hidden] {
    display: none !important;
}

@keyframes artPetPanelIn {
    from { opacity: 0; transform: translateY(8px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.art-pet-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 17px 18px 13px;
    border-bottom: 1px solid rgba(166, 149, 196, 0.15);
    background: linear-gradient(135deg, rgba(247, 244, 255, 0.98), rgba(255, 249, 245, 0.98));
}

.art-pet-panel-title {
    margin: 0;
    color: #241f3d;
    font-size: 15px;
    font-weight: 800;
}

.art-pet-panel-subtitle {
    margin: 4px 0 0;
    color: #9691ab;
    font-size: 11px;
    line-height: 1.5;
}

.art-pet-panel-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border: 1px solid rgba(166, 149, 196, 0.18);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.86);
    color: #77718e;
    cursor: pointer;
}

.art-pet-actions {
    display: grid;
    gap: 9px;
    padding: 14px;
}

.art-pet-action {
    display: grid;
    grid-template-columns: 38px 1fr auto;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 11px;
    border: 1px solid rgba(166, 149, 196, 0.17);
    border-radius: 15px;
    background: #fbf9fe;
    color: #241f3d;
    text-align: left;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.art-pet-action:hover {
    transform: translateY(-1px);
    border-color: rgba(139, 124, 246, 0.34);
    background: #ffffff;
}

.art-pet-action:disabled {
    cursor: wait;
    opacity: 0.62;
    transform: none;
}

.art-pet-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, #eeeaff, #fff1e8);
    color: #6d5ee8;
    font-size: 15px;
}

.art-pet-action-copy strong,
.art-pet-action-copy span {
    display: block;
}

.art-pet-action-copy strong {
    font-size: 12px;
    font-weight: 800;
}

.art-pet-action-copy span {
    margin-top: 2px;
    color: #9691ab;
    font-size: 10px;
    line-height: 1.45;
}

.art-pet-action-arrow {
    color: #aaa5ba;
    font-size: 10px;
}

.art-pet-result {
    padding: 14px;
}

.art-pet-result-note {
    margin: 0 0 9px;
    color: #6d6887;
    font-size: 11px;
    line-height: 1.55;
}

.art-pet-result-text {
    width: 100%;
    min-height: 154px;
    resize: vertical;
    border: 1px solid rgba(166, 149, 196, 0.22);
    border-radius: 14px;
    background: #faf8fd;
    padding: 11px 12px;
    color: #302a4a;
    font: inherit;
    font-size: 12px;
    line-height: 1.65;
    outline: none;
}

.art-pet-result-text:focus {
    border-color: rgba(139, 124, 246, 0.55);
    box-shadow: 0 0 0 3px rgba(139, 124, 246, 0.1);
}

.art-pet-result-buttons {
    display: flex;
    gap: 9px;
    margin-top: 11px;
}

.art-pet-result-button {
    flex: 1;
    padding: 9px 12px;
    border-radius: 999px;
    border: 1px solid rgba(166, 149, 196, 0.22);
    background: #ffffff;
    color: #6d6887;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
}

.art-pet-result-button.is-primary {
    border-color: #171526;
    background: #171526;
    color: #ffffff;
}

body[data-theme="light"] .art-pet-panel,
body[data-theme="light"] .art-pet-bubble {
    color-scheme: light;
}

#userCenterModal > .component-bg {
    max-height: calc(100vh - 32px);
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

.pet-settings-card {
    margin-bottom: 16px;
    padding: 14px 16px;
    border-radius: 12px;
}

.pet-settings-heading,
.pet-settings-title-wrap,
.pet-size-label-row,
.pet-size-scale {
    display: flex;
    align-items: center;
}

.pet-settings-heading,
.pet-size-label-row,
.pet-size-scale {
    justify-content: space-between;
}

.pet-settings-title-wrap {
    min-width: 0;
    gap: 10px;
}

.pet-settings-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    color: #7c3aed;
    background: rgba(139, 92, 246, 0.11);
    font-size: 14px;
}

.pet-settings-title {
    margin: 0;
    color: #241f3d;
    font-size: 14px;
    font-weight: 800;
}

.pet-settings-description {
    margin: 2px 0 0;
    color: #9691ab;
    font-size: 10px;
    line-height: 1.45;
}

.pet-settings-switch {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    margin-left: 12px;
    cursor: pointer;
}

.pet-settings-switch input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.pet-settings-switch-track {
    position: relative;
    display: block;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: #d9d4e5;
    box-shadow: inset 0 0 0 1px rgba(84, 72, 111, 0.08);
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.pet-settings-switch-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(36, 31, 61, 0.22);
    transition: transform 0.2s ease;
}

.pet-settings-switch input:checked + .pet-settings-switch-track {
    background: linear-gradient(135deg, #8b7cf6, #6d5ee8);
    box-shadow: 0 4px 10px rgba(109, 94, 232, 0.22);
}

.pet-settings-switch input:checked + .pet-settings-switch-track::after {
    transform: translateX(18px);
}

.pet-settings-switch input:focus-visible + .pet-settings-switch-track {
    outline: 3px solid rgba(139, 124, 246, 0.25);
    outline-offset: 2px;
}

.pet-size-control {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(166, 149, 196, 0.15);
    transition: opacity 0.2s ease;
}

.pet-size-control.is-disabled {
    opacity: 0.42;
}

.pet-size-label-row {
    color: #6d6887;
    font-size: 11px;
    font-weight: 700;
}

#petSizeValue {
    min-width: 42px;
    padding: 3px 7px;
    border-radius: 999px;
    color: #6d5ee8;
    background: rgba(139, 124, 246, 0.1);
    text-align: center;
    font-size: 10px;
    font-weight: 800;
}

.pet-size-slider {
    width: 100%;
    height: 5px;
    margin: 13px 0 7px;
    border-radius: 999px;
    outline: none;
    background: linear-gradient(90deg, #8b7cf6, #c4b5fd);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.pet-size-slider:disabled {
    cursor: not-allowed;
}

.pet-size-slider::-webkit-slider-thumb {
    width: 18px;
    height: 18px;
    border: 3px solid #ffffff;
    border-radius: 50%;
    background: #6d5ee8;
    box-shadow: 0 2px 7px rgba(76, 61, 169, 0.32);
    appearance: none;
    -webkit-appearance: none;
}

.pet-size-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: 3px solid #ffffff;
    border-radius: 50%;
    background: #6d5ee8;
    box-shadow: 0 2px 7px rgba(76, 61, 169, 0.32);
}

.pet-size-slider:focus-visible {
    box-shadow: 0 0 0 3px rgba(139, 124, 246, 0.18);
}

.pet-size-scale {
    color: #aaa5ba;
    font-size: 9px;
}

.pet-settings-hint {
    margin: 9px 0 0;
    color: #aaa5ba;
    font-size: 9px;
    line-height: 1.5;
}

body:not([data-theme="light"]) .pet-settings-title {
    color: #f4f0ff;
}

body:not([data-theme="light"]) .pet-settings-icon {
    color: #c4b5fd;
    background: rgba(139, 92, 246, 0.16);
}

body:not([data-theme="light"]) .pet-size-control {
    border-top-color: rgba(255, 255, 255, 0.08);
}

@media (max-width: 720px) {
    .art-pet {
        right: max(10px, env(safe-area-inset-right));
        bottom: max(10px, env(safe-area-inset-bottom));
        width: 102px;
        height: 112px;
    }

    .art-pet-character,
    .art-pet-sprite {
        width: 96px;
        height: 104px;
    }

    .art-pet-panel {
        position: fixed;
        right: 12px;
        bottom: var(--art-pet-mobile-panel-bottom, var(--art-pet-panel-bottom, 112px));
        max-height: calc(100vh - 24px);
        overflow-y: auto;
    }

    .art-pet.aligns-panel-left .art-pet-panel {
        right: auto;
        left: 12px;
    }

    .art-pet.opens-panel-below .art-pet-panel,
    .art-pet.aligns-panel-left.opens-panel-below .art-pet-panel {
        top: var(--art-pet-mobile-panel-top, 12px);
        bottom: auto;
    }

    .art-pet-bubble {
        right: var(--art-pet-bubble-right, 70px);
        bottom: var(--art-pet-bubble-bottom, 88px);
    }

    .art-pet.is-roaming {
        transform: translateX(var(--art-pet-roam-distance, -48px));
    }
}

@media (prefers-reduced-motion: reduce) {
    .art-pet,
    .art-pet-character,
    .art-pet-panel,
    .art-pet-bubble,
    .art-pet-action {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}
