:root {
    color-scheme: light;
    font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #e7eeea;
    color: #17201d;
    font-synthesis: none;
}

* {
    box-sizing: border-box;
    letter-spacing: 0;
}

[hidden] {
    display: none !important;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.pet-shell {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 520px;
    isolation: isolate;
    background: #dfe8e3 url("backgrounds/seaside.png") center / cover no-repeat;
    transition: background-image 320ms ease;
}

.pet-shell[data-background="dream-room"] {
    background-image: url("backgrounds/dream-room.png");
}

.pet-shell[data-background="city-night"] {
    background-image: url("backgrounds/city-night.png");
}

.pet-shell[data-background="seaside"] {
    background-image: url("backgrounds/seaside.png");
}

.pet-shell[data-background="old-money"] {
    background-image: url("backgrounds/old-money.png");
    background-position: center 54%;
}

.pet-shell[data-background="cute-pink"] {
    background-image: url("backgrounds/cute-pink.png");
    background-position: center 52%;
}

.pet-shell[data-background="warm-home"] {
    background-image: url("backgrounds/warm-home.png");
    background-position: center 46%;
}

.pet-shell[data-background="dusk-balcony"] {
    background-image: url("backgrounds/dusk-balcony.png");
    background-position: center 42%;
}

.pet-shell[data-background="sunny-lawn"] {
    background-image: url("backgrounds/sunny-lawn.png");
    background-position: center 58%;
}

.pet-shell[data-background="custom"] {
    background-image: var(--custom-background-image, url("backgrounds/seaside.png"));
}

.pet-shell::before {
    position: absolute;
    inset: 0;
    z-index: -1;
    content: "";
    background: rgba(239, 245, 241, 0.1);
    pointer-events: none;
}

.pet-shell[data-background="dream-room"]::before {
    background: rgba(255, 247, 250, 0.08);
}

.pet-shell[data-background="city-night"]::before {
    background: rgba(226, 235, 240, 0.12);
}

.pet-shell[data-background="seaside"]::before {
    background: rgba(238, 247, 247, 0.08);
}

.pet-shell[data-background="old-money"]::before {
    background: rgba(40, 31, 14, 0.04);
}

.pet-shell[data-background="cute-pink"]::before {
    background: rgba(255, 246, 249, 0.04);
}

.pet-shell[data-background="warm-home"]::before {
    background: rgba(92, 58, 28, 0.06);
}

.pet-shell[data-background="dusk-balcony"]::before {
    background: rgba(28, 24, 48, 0.08);
}

.pet-shell[data-background="sunny-lawn"]::before {
    background: rgba(232, 246, 232, 0.06);
}

.pet-shell[data-background="custom"]::before {
    background: rgba(239, 245, 241, 0.06);
}

.topbar {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 68px;
    padding: max(16px, env(safe-area-inset-top)) clamp(16px, 4vw, 48px) 12px;
}

.brand {
    display: flex;
    align-items: baseline;
    gap: 14px;
}

.brand strong {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 30px;
    font-weight: 700;
    line-height: 1;
}

.connection-state {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #56645e;
    font-size: 13px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d09245;
}

.connection-state[data-state="online"] .status-dot {
    background: #278a63;
}

.connection-state[data-state="local"] .status-dot {
    background: #b8782f;
}

.connection-state[data-state="offline"] .status-dot,
.connection-state[data-state="error"] .status-dot {
    background: #c45252;
}

.topbar-actions {
    display: flex;
    gap: 8px;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.icon-button svg {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
}

.play-dock {
    position: absolute;
    top: max(76px, calc(env(safe-area-inset-top) + 62px));
    left: clamp(16px, 4vw, 48px);
    z-index: 19;
    display: flex;
    gap: 7px;
}

.play-menu summary {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 62px;
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid rgba(23, 32, 29, 0.16);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.68);
    color: #26322e;
    font-size: 13px;
    list-style: none;
    cursor: pointer;
    backdrop-filter: blur(12px);
}

.play-menu summary::-webkit-details-marker {
    display: none;
}

.play-menu[open] summary,
.play-menu summary:hover {
    border-color: rgba(23, 32, 29, 0.32);
    background: rgba(255, 255, 255, 0.94);
}

.play-panel {
    position: fixed;
    top: max(122px, calc(env(safe-area-inset-top) + 108px));
    left: clamp(16px, 4vw, 48px);
    z-index: 30;
    padding: 10px;
    border: 1px solid rgba(23, 32, 29, 0.16);
    border-radius: 8px;
    background: rgba(248, 251, 249, 0.94);
    box-shadow: 0 14px 36px rgba(22, 37, 31, 0.18);
    backdrop-filter: blur(16px);
}

.grouped-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: min(420px, calc(100vw - 24px));
    max-height: min(64vh, 560px);
    overflow: auto;
}

.group-block h3 {
    margin: 0 0 8px;
    color: #56645e;
    font-size: 12px;
    font-weight: 600;
}

.theme-panel {
    display: grid;
    grid-template-columns: repeat(2, 148px);
    gap: 8px;
}

.theme-panel button {
    display: grid;
    gap: 7px;
    padding: 6px;
    border: 2px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: #26322e;
    text-align: left;
}

.theme-panel button:hover,
.theme-panel button[aria-pressed="true"] {
    border-color: #4d806c;
    background: #edf6f1;
}

.theme-panel strong,
.theme-panel small {
    display: block;
}

.theme-panel strong {
    font-size: 13px;
}

.theme-panel small {
    margin-top: 2px;
    color: #68766f;
    font-size: 11px;
}

.theme-thumb {
    display: block;
    width: 132px;
    aspect-ratio: 16 / 9;
    border-radius: 4px;
    background-position: center;
    background-size: cover;
}

.theme-thumb.old-money { background-image: url("backgrounds/old-money.png"); }
.theme-thumb.cute-pink { background-image: url("backgrounds/cute-pink.png"); }
.theme-thumb.warm-home { background-image: url("backgrounds/warm-home.png"); }
.theme-thumb.dusk-balcony { background-image: url("backgrounds/dusk-balcony.png"); }
.theme-thumb.sunny-lawn { background-image: url("backgrounds/sunny-lawn.png"); }

.action-panel {
    display: grid;
    grid-template-columns: repeat(4, 76px);
    gap: 7px;
}

.action-panel button,
.eye-style-grid button {
    min-height: 40px;
    padding: 0 10px;
    border: 1px solid #c8d2cd;
    border-radius: 5px;
    background: #fff;
    color: #25312d;
    font-size: 13px;
}

.action-panel button:hover,
.eye-style-grid button:hover,
.eye-style-grid button[aria-pressed="true"] {
    border-color: #4d806c;
    background: #edf6f1;
}

.eye-panel {
    width: 326px;
}

.eye-style-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
}

.eye-color-row {
    display: flex;
    justify-content: space-between;
    gap: 9px;
    margin-top: 11px;
    padding-top: 11px;
    border-top: 1px solid rgba(23, 32, 29, 0.12);
}

.eye-color-row button {
    width: 34px;
    height: 34px;
    padding: 4px;
    border: 2px solid transparent;
    border-radius: 50%;
    background: var(--swatch);
    background-clip: content-box;
}

.eye-color-row button:hover,
.eye-color-row button[aria-pressed="true"] {
    border-color: #26322e;
}

.skin-panel {
    display: grid;
    grid-template-columns: repeat(2, 130px);
    gap: 8px;
}

.skin-panel button {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    min-height: 50px;
    padding: 4px 8px 4px 4px;
    border: 2px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: #26322e;
    font-size: 12px;
    text-align: left;
}

.skin-panel button:hover,
.skin-panel button[aria-pressed="true"] {
    border-color: #4d806c;
    background: #edf6f1;
}

.skin-thumb {
    width: 42px;
    height: 42px;
    border: 1px solid rgba(23, 32, 29, 0.15);
    border-radius: 6px;
    background-color: #fff7e3;
}

.skin-thumb.classic-cream {
    background: #fff7e3;
}

.skin-thumb.sakura-cream {
    background:
        radial-gradient(circle at 25% 28%, #efabb4 0 2px, transparent 3px),
        radial-gradient(circle at 72% 68%, #efabb4 0 2px, transparent 3px),
        #df94a4;
}

.skin-thumb.midnight-cosmos {
    background:
        radial-gradient(circle at 28% 30%, #f2d594 0 2px, transparent 3px),
        radial-gradient(circle at 70% 62%, #dbe4f2 0 3px, transparent 4px),
        #829bc5;
}

.skin-thumb.mint-waves {
    background:
        radial-gradient(ellipse at 25% 30%, #fff 0 3px, transparent 4px),
        radial-gradient(circle at 70% 68%, #92cfc2 0 2px, transparent 3px),
        #79bea8;
}

.skin-thumb.honey-gingham {
    background:
        radial-gradient(circle at 28% 32%, #fff 0 3px, transparent 4px),
        radial-gradient(ellipse at 70% 68%, #aeb66d 0 2px, transparent 3px),
        #d7a641;
}

.skin-thumb.wealth-gold {
    background:
        linear-gradient(135deg, transparent 42%, rgba(32, 79, 56, 0.82) 43% 48%, transparent 49%),
        radial-gradient(circle at 28% 28%, #285039 0 3px, #d5aa42 4px 6px, transparent 7px),
        radial-gradient(circle at 72% 68%, #285039 0 3px, #d5aa42 4px 6px, transparent 7px),
        #e0bd62;
}

.skin-thumb.cute-pink {
    background:
        radial-gradient(circle at 28% 28%, #fff 0 2px, #ef6599 3px 6px, transparent 7px),
        radial-gradient(circle at 70% 68%, #f05b94 0 5px, transparent 6px),
        #ef91b2;
}

.skin-thumb.tea-linen {
    background:
        repeating-linear-gradient(90deg, #e8d3b0 0 10px, #f4ead8 10px 20px),
        #e6d2ae;
}

.skin-thumb.oat-mist {
    background:
        repeating-linear-gradient(90deg, #9aafc0 0 3px, #e6e0d4 3px 14px),
        #d9d3c7;
}

.skin-thumb.meadow-dots {
    background:
        radial-gradient(circle at 30% 30%, #fff 0 3px, transparent 4px),
        radial-gradient(circle at 70% 62%, #8ec7e8 0 4px, transparent 5px),
        #9fc98a;
}

.scene-panel {
    display: grid;
    grid-template-columns: repeat(3, 110px);
    gap: 8px;
}

.scene-panel button {
    display: grid;
    gap: 6px;
    padding: 5px 5px 8px;
    border: 2px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: #26322e;
    font-size: 12px;
}

.scene-panel button:hover,
.scene-panel button[aria-pressed="true"] {
    border-color: #4d806c;
    background: #edf6f1;
}

.scene-thumb {
    display: block;
    width: 96px;
    aspect-ratio: 16 / 9;
    border-radius: 4px;
    background-position: center;
    background-size: cover;
}

.scene-thumb.dream-room { background-image: url("backgrounds/dream-room.png"); }
.scene-thumb.city-night { background-image: url("backgrounds/city-night.png"); }
.scene-thumb.seaside { background-image: url("backgrounds/seaside.png"); }
.scene-thumb.old-money { background-image: url("backgrounds/old-money.png"); }
.scene-thumb.cute-pink { background-image: url("backgrounds/cute-pink.png"); }
.scene-thumb.warm-home { background-image: url("backgrounds/warm-home.png"); }
.scene-thumb.dusk-balcony { background-image: url("backgrounds/dusk-balcony.png"); }
.scene-thumb.sunny-lawn { background-image: url("backgrounds/sunny-lawn.png"); }

.pet-shell[data-theme-preset="old-money"] .brand,
.pet-shell[data-theme-preset="old-money"] .connection-state {
    color: #fff4c5;
    text-shadow: 0 1px 4px rgba(16, 25, 18, 0.72);
}

.pet-shell[data-theme-preset="old-money"] .quiet-button,
.pet-shell[data-theme-preset="old-money"] .play-menu summary {
    border-color: rgba(220, 181, 76, 0.72);
    background: rgba(25, 61, 43, 0.9);
    color: #fff0b3;
}

.pet-shell[data-theme-preset="old-money"] .send-button,
.pet-shell[data-theme-preset="old-money"] .message.user {
    border-color: #cda33d;
    background: #234f39;
    color: #fff2bd;
}

.pet-shell[data-theme-preset="cute-pink"] .brand,
.pet-shell[data-theme-preset="cute-pink"] .connection-state {
    color: #b72e67;
}

.pet-shell[data-theme-preset="cute-pink"] .quiet-button,
.pet-shell[data-theme-preset="cute-pink"] .play-menu summary {
    border-color: rgba(222, 91, 144, 0.42);
    background: rgba(255, 248, 251, 0.9);
    color: #a52d5c;
}

.pet-shell[data-theme-preset="cute-pink"] .send-button,
.pet-shell[data-theme-preset="cute-pink"] .message.user {
    border-color: #db4d88;
    background: #df5b91;
    color: #fff;
}

.pet-shell[data-theme-preset="warm-home"] .brand,
.pet-shell[data-theme-preset="warm-home"] .connection-state {
    color: #5c3a1c;
    text-shadow: 0 1px 4px rgba(255, 236, 210, 0.7);
}

.pet-shell[data-theme-preset="warm-home"] .quiet-button,
.pet-shell[data-theme-preset="warm-home"] .play-menu summary {
    border-color: rgba(176, 122, 64, 0.45);
    background: rgba(255, 246, 232, 0.9);
    color: #6a4220;
}

.pet-shell[data-theme-preset="warm-home"] .send-button,
.pet-shell[data-theme-preset="warm-home"] .message.user {
    border-color: #b07a40;
    background: #8a5a2b;
    color: #fff6e8;
}

.pet-shell[data-theme-preset="dusk-balcony"] .brand,
.pet-shell[data-theme-preset="dusk-balcony"] .connection-state {
    color: #fff1e0;
    text-shadow: 0 1px 4px rgba(40, 24, 16, 0.72);
}

.pet-shell[data-theme-preset="dusk-balcony"] .quiet-button,
.pet-shell[data-theme-preset="dusk-balcony"] .play-menu summary {
    border-color: rgba(232, 140, 72, 0.5);
    background: rgba(48, 32, 40, 0.82);
    color: #ffe4c8;
}

.pet-shell[data-theme-preset="dusk-balcony"] .send-button,
.pet-shell[data-theme-preset="dusk-balcony"] .message.user {
    border-color: #e08a48;
    background: #c45c28;
    color: #fff4ea;
}

.pet-shell[data-theme-preset="sunny-lawn"] .brand,
.pet-shell[data-theme-preset="sunny-lawn"] .connection-state {
    color: #2f6a38;
    text-shadow: 0 1px 4px rgba(255, 255, 255, 0.55);
}

.pet-shell[data-theme-preset="sunny-lawn"] .quiet-button,
.pet-shell[data-theme-preset="sunny-lawn"] .play-menu summary {
    border-color: rgba(90, 168, 92, 0.45);
    background: rgba(245, 255, 242, 0.9);
    color: #2f6a38;
}

.pet-shell[data-theme-preset="sunny-lawn"] .send-button,
.pet-shell[data-theme-preset="sunny-lawn"] .message.user {
    border-color: #5aa85c;
    background: #3e8f4a;
    color: #fff;
}

.custom-background-thumb {
    position: relative;
    background-color: #dfe8e3;
    background-image: var(--custom-background-image, none);
}

.custom-background-thumb:not([data-ready="true"])::after {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    content: "+";
    color: #52615b;
    font-size: 28px;
    font-weight: 400;
}

.quiet-button,
.secondary-button,
.primary-button,
.send-button {
    min-height: 40px;
    border-radius: 6px;
}

.quiet-button {
    padding: 0 13px;
    border: 1px solid rgba(23, 32, 29, 0.16);
    background: rgba(255, 255, 255, 0.58);
    color: #26322e;
    backdrop-filter: blur(10px);
}

.quiet-button:hover,
.quiet-button[aria-pressed="true"] {
    border-color: rgba(23, 32, 29, 0.3);
    background: rgba(255, 255, 255, 0.88);
}

.pet-stage,
#live2d-stage {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

#live2d-stage {
    touch-action: none;
    cursor: grab;
}

#live2d-stage:active {
    cursor: grabbing;
}

.money-effect-layer {
    position: absolute;
    inset: 0;
    z-index: 4;
    overflow: hidden;
    pointer-events: none;
}

.money-particle {
    position: absolute;
    display: block;
    opacity: 0;
    animation-duration: var(--duration);
    animation-delay: var(--delay);
    animation-fill-mode: forwards;
    animation-timing-function: cubic-bezier(0.2, 0.72, 0.28, 1);
    will-change: transform, opacity;
}

.money-bill {
    width: 66px;
    height: 28px;
    border: 1px solid rgba(91, 103, 77, 0.72);
    border-radius: 2px;
    background: #ece7d2 url("effects/dollar-bill.png") center / 100% 100% no-repeat;
    box-shadow: 0 4px 9px rgba(29, 31, 20, 0.28);
    animation-name: money-bill-fall;
}

.money-bill-1 { filter: brightness(0.96) saturate(1.12); }
.money-bill-2 { filter: brightness(1.04) contrast(1.04); }

.gold-dust {
    width: var(--size);
    height: var(--size);
    border-radius: 1px;
    background: #f5d66c;
    animation-name: gold-dust-fall;
}

.gold-dust-1 { background: #d7a82d; }
.gold-dust-2 { background: #fff0a8; }

@keyframes money-bill-fall {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) rotate(0deg) scale(0.62);
    }
    16% {
        opacity: 1;
    }
    32% {
        transform: translate(calc(-50% + var(--mid-x)), calc(-50% - var(--lift))) rotate(var(--spin-mid)) scale(1);
    }
    72% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translate(calc(-50% + var(--drift-x)), calc(-50% + var(--fall))) rotate(var(--spin)) scale(0.9);
    }
}

@keyframes gold-dust-fall {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) rotate(0deg) scale(0.45);
    }
    18% {
        opacity: 1;
    }
    38% {
        transform: translate(calc(-50% + var(--mid-x)), calc(-50% - var(--lift))) rotate(var(--spin-mid)) scale(1);
    }
    62% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translate(calc(-50% + var(--drift-x)), calc(-50% + var(--fall))) rotate(var(--spin)) scale(0.35);
    }
}

.model-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #4f5d57;
    font-size: 14px;
    pointer-events: none;
    z-index: 5;
}

.loading-mark {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(39, 138, 99, 0.24);
    border-top-color: #278a63;
    border-radius: 50%;
    animation: spin 0.85s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.pet-thought {
    position: absolute;
    top: 18%;
    left: 50%;
    max-width: min(360px, 78vw);
    padding: 10px 13px;
    transform: translateX(-50%);
    border: 1px solid rgba(23, 32, 29, 0.12);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 8px 28px rgba(35, 55, 47, 0.12);
    font-size: 14px;
    line-height: 1.45;
    text-align: center;
    z-index: 5;
}

.conversation {
    position: absolute;
    right: clamp(16px, 4vw, 48px);
    bottom: max(20px, env(safe-area-inset-bottom));
    left: clamp(16px, 4vw, 48px);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    pointer-events: none;
}

.message-stream {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(680px, 100%);
    max-height: 178px;
    overflow: hidden;
    mask-image: linear-gradient(to bottom, transparent 0, #000 28px, #000 100%);
}

.message {
    max-width: min(520px, 88%);
    padding: 9px 12px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 4px 18px rgba(35, 55, 47, 0.08);
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
    pointer-events: auto;
}

.message.user {
    align-self: flex-end;
    background: #285e4b;
    color: #fff;
}

.message.assistant {
    align-self: flex-start;
}

.message.assistant[data-streaming]::after {
    content: "";
    display: inline-block;
    width: 2px;
    height: 0.95em;
    margin-left: 2px;
    vertical-align: text-bottom;
    background: #285e4b;
    animation: message-caret 1s steps(2, start) infinite;
}

@keyframes message-caret {
    to {
        visibility: hidden;
    }
}

@media (prefers-reduced-motion: reduce) {
    .message.assistant[data-streaming]::after {
        animation: none;
    }
}

.composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px 64px;
    gap: 8px;
    width: min(680px, 100%);
    padding: 6px;
    border: 1px solid rgba(23, 32, 29, 0.14);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 10px 32px rgba(35, 55, 47, 0.14);
    backdrop-filter: blur(14px);
    pointer-events: auto;
}

.composer input {
    min-width: 0;
    height: 42px;
    padding: 0 12px;
    border: 0;
    outline: 0;
    background: transparent;
    color: #17201d;
}

.composer input::placeholder {
    color: #74817b;
}

.composer input:focus-visible {
    box-shadow: inset 0 -2px #278a63;
}

.send-button,
.primary-button {
    border: 1px solid #285e4b;
    background: #285e4b;
    color: #fff;
}

.send-button:hover,
.primary-button:hover {
    background: #204d3d;
}

.send-button:disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

.mic-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    min-width: 42px;
    padding: 0;
    border: 1px solid rgba(23, 32, 29, 0.2);
    background: rgba(255, 255, 255, 0.7);
    color: #17201d;
}

.mic-button svg {
    width: 20px;
    height: 20px;
}

.mic-button:hover {
    background: rgba(255, 255, 255, 0.92);
}

.mic-button:disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

.mic-button[aria-pressed="true"] {
    border-color: #278a63;
    background: #278a63;
    color: #fff;
    animation: mic-pulse 2s ease-in-out infinite;
}

@keyframes mic-pulse {
    50% {
        box-shadow: 0 0 0 6px rgba(39, 138, 99, 0.24);
    }
}

@media (prefers-reduced-motion: reduce) {
    .mic-button[aria-pressed="true"] {
        animation: none;
    }
}

.settings-dialog {
    width: min(440px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid rgba(23, 32, 29, 0.18);
    border-radius: 8px;
    background: #f8faf9;
    color: #17201d;
    box-shadow: 0 24px 70px rgba(18, 30, 25, 0.28);
}

.settings-dialog::backdrop {
    background: rgba(19, 28, 24, 0.48);
    backdrop-filter: blur(3px);
}

.settings-dialog form {
    display: grid;
    gap: 16px;
    padding: 20px;
}

.dialog-head,
.dialog-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.dialog-head h2 {
    margin: 0;
    font-size: 18px;
}

.close-button {
    width: 36px;
    height: 36px;
    border: 0;
    background: transparent;
    color: #54615b;
    font-size: 27px;
    line-height: 1;
}

.settings-dialog label {
    display: grid;
    gap: 7px;
    color: #4f5d57;
    font-size: 13px;
}

.settings-dialog input,
.settings-dialog select {
    width: 100%;
    height: 42px;
    padding: 0 11px;
    border: 1px solid #cbd5d0;
    border-radius: 5px;
    outline: 0;
    background: #fff;
    color: #17201d;
}

.settings-dialog input:focus,
.settings-dialog select:focus {
    border-color: #278a63;
    box-shadow: 0 0 0 3px rgba(39, 138, 99, 0.12);
}

.dialog-actions {
    justify-content: flex-end;
    margin-top: 4px;
}

.secondary-button,
.primary-button {
    padding: 0 16px;
}

.secondary-button {
    border: 1px solid #c5d0cb;
    background: #fff;
    color: #26322e;
}

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

@media (max-width: 640px) {
    .pet-shell {
        min-height: 460px;
    }

    .topbar {
        min-height: 52px;
        padding-top: max(10px, env(safe-area-inset-top));
        padding-right: 10px;
        padding-left: 10px;
    }

    .brand {
        gap: 8px;
    }

    .brand strong {
        font-size: 22px;
    }

    #connectionLabel {
        display: none;
    }

    .btn-text {
        display: none;
    }

    .quiet-button.icon-button {
        width: 36px;
        min-width: 36px;
        min-height: 36px;
        padding: 0;
        justify-content: center;
    }

    .play-dock {
        top: max(54px, calc(env(safe-area-inset-top) + 44px));
        right: 12px;
        left: 12px;
        justify-content: flex-start;
        gap: 8px;
    }

    .play-menu summary {
        min-width: 50px;
        min-height: 35px;
        padding: 0 7px;
        font-size: 12px;
    }

    .play-panel {
        top: max(96px, calc(env(safe-area-inset-top) + 86px));
        right: 12px;
        left: 12px;
        width: auto;
        max-height: min(58vh, 480px);
    }

    .theme-panel {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .theme-thumb {
        width: 100%;
    }

    .action-panel {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .eye-style-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .eye-color-row {
        display: grid;
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 4px;
    }

    .eye-color-row button {
        width: 30px;
        height: 30px;
    }

    .skin-panel {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .scene-panel {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .scene-thumb {
        width: 100%;
    }

    .pet-shell:has(.play-menu[open]) .pet-thought {
        top: 38%;
    }

    .conversation {
        left: 10px;
        right: 10px;
        bottom: max(10px, env(safe-area-inset-bottom));
        gap: 8px;
    }

    .message-stream {
        max-height: min(28vh, 220px);
        overflow-y: auto;
        mask-image: none;
        -webkit-overflow-scrolling: touch;
    }

    .message {
        font-size: 13px;
        padding: 8px 10px;
    }

    .composer {
        grid-template-columns: minmax(0, 1fr) 42px 56px;
    }

    .send-button {
        padding: 0 8px;
        font-size: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
