:root {
    --pet-ink: #252722;
    --pet-sage: #91a27e;
    --pet-sage-deep: #66775a;
    --pet-paper: #fafaf7;
    --pet-glass: rgba(250, 250, 247, 0.9);
    --pet-ease-out: cubic-bezier(0.25, 1, 0.5, 1);
}

.hero-copy {
    position: relative;
    z-index: 1;
    max-width: 410px;
}

.pet-home {
    --pet-travel-x: 228px;
    position: absolute;
    top: 136px;
    right: 178px;
    z-index: 4;
    width: 164px;
    height: 190px;
}

.pet-button {
    position: absolute;
    inset: 24px 0 auto;
    width: 164px;
    height: 164px;
    border: 0;
    border-radius: 48%;
    background: transparent;
    color: inherit;
    cursor: pointer;
    touch-action: manipulation;
    transform-origin: 50% 88%;
}

.pet-button::before {
    content: '';
    position: absolute;
    inset: 12px;
    border-radius: 50%;
    background: rgba(145, 162, 126, 0);
    transition: background-color 220ms var(--pet-ease-out), transform 220ms var(--pet-ease-out);
}

.pet-chat button:focus-visible,
.pet-chat input:focus-visible {
    outline: 2px solid var(--site-focus, #315f4b);
    outline-offset: 4px;
}

.pet-button:focus-visible { outline: none; }
.pet-button:focus-visible::before { background: rgba(145, 162, 126, 0.12); }
.pet-button:focus-visible .pet-outline path,
.pet-button:focus-visible .pet-mouth { stroke: var(--pet-sage-deep); }

.pet {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
    transform-origin: 50% 88%;
}

.pet-character {
    transform-origin: 90px 145px;
    transition: transform 180ms var(--pet-ease-out);
}

.pet-outline path,
.pet-mouth {
    fill: none;
    stroke: var(--pet-ink);
    stroke-width: 2.65;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.pet-eye { fill: var(--pet-ink); }
.pet-mouth { stroke-width: 2.5; }

.pet-upper,
.pet-lower,
.pet-eyes,
.pet-foot {
    transform-box: fill-box;
}

.pet-upper { transform-origin: 50% 88%; }
.pet-lower { transform-origin: 50% 10%; }
.pet-eyes { transform-origin: center; }
.pet-foot { transform-origin: 50% 0; }

.pet-home.is-pacing .pet-button {
    animation: pet-pace 16s linear;
    will-change: transform;
}
.pet-home.is-pacing .pet-upper { animation: pet-look-around 16s cubic-bezier(0.25, 1, 0.5, 1); }
.pet-home.is-pacing .pet-eyes { animation: pet-eye-look 16s cubic-bezier(0.25, 1, 0.5, 1); }
.pet-home.is-pacing .pet-foot--left { animation: pet-foot-left 1.2s ease-in-out infinite; }
.pet-home.is-pacing .pet-foot--right { animation: pet-foot-right 1.2s ease-in-out 0.6s infinite; }

.pet-chat[hidden] { display: none; }

.pet-chat {
    position: fixed;
    top: clamp(112px, 18vh, 156px);
    right: max(28px, env(safe-area-inset-right));
    width: min(360px, calc(100vw - 32px));
    padding: 20px;
    border: 1px solid rgba(37, 39, 34, 0.14);
    border-radius: 22px;
    background: rgba(250, 250, 247, 0.76);
    box-shadow:
        0 24px 72px rgba(51, 56, 46, 0.14),
        inset 0 1px 0 rgba(252, 252, 249, 0.84);
    color: var(--pet-ink);
    transform-origin: 100% 18%;
    animation: pet-chat-in 280ms var(--pet-ease-out) both;
}

@supports ((backdrop-filter: blur(22px)) or (-webkit-backdrop-filter: blur(22px))) {
    .pet-chat {
        background: rgba(250, 250, 247, 0.64);
        -webkit-backdrop-filter: blur(22px) saturate(0.88);
        backdrop-filter: blur(22px) saturate(0.88);
    }
}

.pet-chat__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.pet-chat__title {
    font-family: 'Noto Serif SC', serif;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
}

.pet-chat__status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    color: #7b7e75;
    font-size: 11px;
    line-height: 1.4;
}

.pet-chat__status span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--pet-sage);
}

.pet-chat__close {
    width: 44px;
    height: 44px;
    margin: -10px -10px 0 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #73766e;
    font: 300 24px/1 system-ui, sans-serif;
    cursor: pointer;
    transition: background-color 150ms ease-out, color 150ms ease-out;
}

@media (hover: hover) {
    .pet-chat__close:hover { background: rgba(37, 39, 34, 0.06); color: var(--pet-ink); }
}

.pet-chat__messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 190px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.pet-message {
    width: fit-content;
    max-width: 86%;
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.65;
    text-wrap: pretty;
}

.pet-message p + p { margin-top: 2px; }
.pet-message--pet { align-self: flex-start; background: rgba(145, 162, 126, 0.12); }
.pet-message--visitor { align-self: flex-end; background: rgba(37, 39, 34, 0.065); }

.pet-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 14px;
}

.pet-prompts button {
    min-height: 44px;
    padding: 7px 10px;
    border: 1px solid rgba(37, 39, 34, 0.12);
    border-radius: 999px;
    background: rgba(250, 250, 247, 0.62);
    color: #585b53;
    font: inherit;
    font-size: 11px;
    line-height: 1.4;
    cursor: pointer;
    transition: border-color 150ms ease-out, background-color 150ms ease-out, transform 100ms ease-out;
}

.pet-prompts button:disabled {
    cursor: default;
    opacity: 0.48;
}

@media (hover: hover) {
    .pet-prompts button:hover { border-color: rgba(102, 119, 90, 0.44); background: rgba(145, 162, 126, 0.1); }
}

.pet-prompts button:active,
.pet-chat__form button:active { transform: scale(0.97); }

.pet-chat__form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(37, 39, 34, 0.09);
}

.pet-chat__form input {
    min-width: 0;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid rgba(37, 39, 34, 0.13);
    border-radius: 12px;
    background: rgba(250, 250, 247, 0.74);
    color: var(--pet-ink);
    font: inherit;
    font-size: 13px;
}

.pet-chat__form input::placeholder { color: #74776e; opacity: 1; }

.pet-chat__form button {
    min-width: 58px;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--pet-ink);
    border-radius: 12px;
    background: var(--pet-ink);
    color: var(--pet-paper);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: transform 100ms ease-out, background-color 150ms ease-out;
}

.pet-chat__form button:disabled,
.pet-chat__form input:disabled {
    cursor: wait;
    opacity: 0.62;
}

.pet-chat__form button:disabled {
    min-width: 72px;
}

.pet-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@keyframes pet-pace {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(var(--pet-travel-x)); }
}

@keyframes pet-look-around {
    0%, 49% { transform: translateX(6px) rotate(2.8deg); }
    51%, 99% { transform: translateX(-6px) rotate(-2.8deg); }
    50%, 100% { transform: translateX(0) rotate(0); }
}

@keyframes pet-eye-look {
    0%, 49% { transform: translateX(3px); }
    51%, 99% { transform: translateX(-3px); }
    50%, 100% { transform: translateX(0); }
}

@keyframes pet-foot-left {
    0%, 50%, 100% { transform: translateY(0) rotate(0); }
    25% { transform: translateY(-4px) rotate(-6deg); }
}

@keyframes pet-foot-right {
    0%, 50%, 100% { transform: translateY(0) rotate(0); }
    25% { transform: translateY(-4px) rotate(6deg); }
}

@keyframes pet-chat-in {
    from { opacity: 0; transform: translateY(-7px) scale(0.975); filter: blur(5px); }
    to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

@media (max-width: 640px) {
    .hero-copy { max-width: 100%; }

    .pet-home {
        --pet-travel-x: 132px;
        top: auto;
        right: 142px;
        bottom: 26px;
        width: 112px;
        height: 132px;
    }

    .pet-button {
        inset: 20px 0 auto;
        width: 112px;
        height: 112px;
    }

    .pet-chat {
        position: fixed;
        right: max(16px, env(safe-area-inset-right));
        bottom: max(16px, env(safe-area-inset-bottom));
        top: auto;
        left: max(16px, env(safe-area-inset-left));
        width: auto;
        max-height: min(560px, calc(100dvh - 32px));
        overflow-y: auto;
        transform-origin: 82% 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pet-home.is-pacing .pet-button,
    .pet-home.is-pacing .pet-upper,
    .pet-home.is-pacing .pet-eyes,
    .pet-home.is-pacing .pet-foot,
    .pet-chat {
        animation: none;
    }

    .pet-button,
    .pet-button::before,
    .pet-chat__close,
    .pet-prompts button,
    .pet-chat__form button { transition: none; }
}
