.mmyww-ai-companion-widget,
.mmyww-ai-companion-widget * {
    box-sizing: border-box;
}

.mmyww-ai-companion-widget-entry {
    position: fixed;
    right: 18px;
    bottom: 86px;
    z-index: 1036;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 96px;
    min-height: 48px;
    padding: 0 15px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #ff4d93, #8b5cf6);
    color: #fff;
    box-shadow: 0 14px 34px rgba(139, 92, 246, 0.28);
    cursor: pointer;
    font-size: 14px;
    font-weight: 800;
    line-height: 1;
    transform: translate3d(0, 0, 0);
    transform-origin: 50% 55%;
    animation: mmyww-ai-companion-widget-float 4.8s ease-in-out infinite;
    will-change: transform, box-shadow;
}

.mmyww-ai-companion-widget-entry:hover,
.mmyww-ai-companion-widget-entry:focus,
.mmyww-ai-companion-widget-entry:focus-visible,
.mmyww-ai-companion-widget-active .mmyww-ai-companion-widget-entry {
    animation-play-state: paused;
}

.mmyww-ai-companion-widget-entry:hover,
.mmyww-ai-companion-widget-entry:focus-visible {
    transform: translate3d(0, -3px, 0) scale(1.02);
    box-shadow: 0 16px 38px rgba(139, 92, 246, 0.32);
}

@keyframes mmyww-ai-companion-widget-float {
    0%,
    100% {
        transform: translate3d(0, 0, 0) scale(1);
        box-shadow: 0 14px 34px rgba(139, 92, 246, 0.28);
    }

    35% {
        transform: translate3d(3px, -8px, 0) scale(1.025);
        box-shadow: 0 18px 42px rgba(255, 77, 147, 0.28);
    }

    70% {
        transform: translate3d(-2px, -3px, 0) scale(1.01);
        box-shadow: 0 15px 36px rgba(139, 92, 246, 0.25);
    }
}

.mmyww-ai-companion-widget-entry-face {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    font-size: 12px;
    letter-spacing: 0;
}

.mmyww-ai-companion-widget-entry-text {
    white-space: nowrap;
}

.mmyww-ai-companion-widget-panel {
    position: fixed;
    right: 18px;
    bottom: 146px;
    z-index: 1037;
    display: flex;
    flex-direction: column;
    width: min(390px, calc(100vw - 28px));
    max-height: min(720px, calc(100vh - 176px));
    max-height: min(720px, calc(100dvh - 176px));
    overflow: hidden;
    border: 1px solid rgba(229, 231, 235, 0.95);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(17, 24, 39, 0.22);
}

.mmyww-ai-companion-widget-panel[hidden] {
    display: none;
}

.mmyww-ai-companion-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 13px 14px;
    border-bottom: 1px solid #f0e7ee;
    background: #fff7fb;
}

.mmyww-ai-companion-widget-title {
    min-width: 0;
    color: #111827;
    font-size: 15px;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mmyww-ai-companion-widget-close,
.mmyww-ai-companion-widget-back,
.mmyww-ai-companion-widget-send,
.mmyww-ai-companion-widget-character {
    font: inherit;
}

.mmyww-ai-companion-widget-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: #4b5563;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
}

.mmyww-ai-companion-widget-body {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    padding: 12px;
}

.mmyww-ai-companion-widget-notice,
.mmyww-ai-companion-widget-age-note,
.mmyww-ai-companion-widget-system {
    border-radius: 8px;
    color: #6b7280;
    font-size: 13px;
    line-height: 1.6;
}

.mmyww-ai-companion-widget-notice {
    margin: 0 0 10px;
    padding: 9px 10px;
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #991b1b;
}

.mmyww-ai-companion-widget-login-text {
    margin-bottom: 8px;
}

.mmyww-ai-companion-widget-login-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mmyww-ai-companion-widget-login-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    background: #ff4d93;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
}

.mmyww-ai-companion-widget-login-link:hover,
.mmyww-ai-companion-widget-login-link:focus {
    color: #fff;
    background: #e11d74;
    text-decoration: none;
}

.mmyww-ai-companion-widget-test-notice {
    margin: 0 0 10px;
    padding: 8px 10px;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    background: #eff6ff;
    color: #1e40af;
    font-size: 12px;
    line-height: 1.55;
}

.mmyww-ai-companion-widget-age-dialog {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(17, 24, 39, 0.36);
}

.mmyww-ai-companion-widget-age-dialog[hidden] {
    display: none;
}

.mmyww-ai-companion-widget-age-dialog-box {
    width: min(100%, 330px);
    padding: 18px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 18px 54px rgba(17, 24, 39, 0.24);
}

.mmyww-ai-companion-widget-age-dialog-title {
    color: #111827;
    font-size: 16px;
    font-weight: 800;
    line-height: 1.4;
}

.mmyww-ai-companion-widget-age-dialog-message {
    margin-top: 10px;
    color: #4b5563;
    font-size: 14px;
    line-height: 1.7;
}

.mmyww-ai-companion-widget-age-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.mmyww-ai-companion-widget-age-confirm-button,
.mmyww-ai-companion-widget-age-cancel-button {
    min-height: 36px;
    padding: 0 12px;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 800;
}

.mmyww-ai-companion-widget-age-confirm-button {
    border: 0;
    background: #ff4d93;
    color: #fff;
}

.mmyww-ai-companion-widget-age-cancel-button {
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #4b5563;
}

.mmyww-ai-companion-widget-age-confirm-button:disabled,
.mmyww-ai-companion-widget-age-cancel-button:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.mmyww-ai-companion-widget-age-note {
    margin: 0 0 10px;
    padding: 9px 10px;
    border: 1px solid #f3e8ff;
    background: #faf5ff;
}

.mmyww-ai-companion-widget-system {
    padding: 10px;
    background: #f9fafb;
}

.mmyww-ai-companion-widget-view {
    min-height: 0;
}

.mmyww-ai-companion-widget-character-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: min(520px, calc(100vh - 250px));
    max-height: min(520px, calc(100dvh - 250px));
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-right: 2px;
}

.mmyww-ai-companion-widget-character {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid #f1d9e8;
    border-radius: 10px;
    background: #fff;
    color: #111827;
    cursor: pointer;
    text-align: left;
}

.mmyww-ai-companion-widget-character:hover,
.mmyww-ai-companion-widget-character:focus {
    border-color: #f9a8d4;
    background: #fff7fb;
}

.mmyww-ai-companion-widget-character-avatar {
    display: inline-flex;
    flex: 0 0 46px;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    overflow: hidden;
    border-radius: 50%;
    background: linear-gradient(135deg, #f9a8d4, #c4b5fd);
    color: #fff;
    font-weight: 800;
}

.mmyww-ai-companion-widget-character-avatar img,
.mmyww-ai-companion-widget-chat-avatar {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mmyww-ai-companion-widget-character-text {
    min-width: 0;
}

.mmyww-ai-companion-widget-character-name {
    display: block;
    color: #111827;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.4;
}

.mmyww-ai-companion-widget-character-description {
    display: block;
    margin-top: 2px;
    color: #6b7280;
    font-size: 13px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.mmyww-ai-companion-widget-view-chat {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
}

.mmyww-ai-companion-widget-chat-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.mmyww-ai-companion-widget-back,
.mmyww-ai-companion-widget-new-story {
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    background: #fff;
    color: #4b5563;
    cursor: pointer;
    font-size: 13px;
}

.mmyww-ai-companion-widget-new-story {
    border-color: #fbcfe8;
    background: #fff7fb;
    color: #be185d;
}

.mmyww-ai-companion-widget-chat-character {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 10px;
}

.mmyww-ai-companion-widget-chat-avatar {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #f3f4f6;
}

.mmyww-ai-companion-widget-chat-name {
    color: #111827;
    font-size: 14px;
    font-weight: 800;
}

.mmyww-ai-companion-widget-messages {
    display: flex;
    flex: 1 1 auto;
    min-height: 180px;
    max-height: min(430px, calc(100vh - 360px));
    max-height: min(430px, calc(100dvh - 360px));
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 10px;
    border: 1px solid #f1e6ee;
    border-radius: 10px;
    background: #fcfcfd;
    scroll-behavior: smooth;
}

.mmyww-ai-companion-widget-messages-rendering {
    visibility: hidden;
    scroll-behavior: auto;
}

.mmyww-ai-companion-widget-message {
    display: flex;
    width: 100%;
    max-width: 100%;
    align-items: flex-end;
    gap: 8px;
    overflow-wrap: anywhere;
    word-break: break-word;
    word-wrap: break-word;
}

.mmyww-ai-companion-widget-message-user {
    justify-content: flex-end;
    color: #1f2937;
}

.mmyww-ai-companion-widget-message-assistant {
    justify-content: flex-start;
    color: #1f2937;
}

.mmyww-ai-companion-widget-message-system {
    align-self: center;
    width: auto;
    max-width: 92%;
}

.mmyww-ai-companion-widget-message-avatar {
    display: inline-flex;
    flex: 0 0 30px;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    overflow: hidden;
    border-radius: 50%;
    background: linear-gradient(135deg, #f472b6, #a78bfa);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}

.mmyww-ai-companion-widget-message-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mmyww-ai-companion-widget-message-bubble {
    max-width: min(82%, 290px);
    padding: 9px 11px;
    border-radius: 13px;
    box-shadow: 0 1px 0 rgba(17, 24, 39, 0.04);
}

.mmyww-ai-companion-widget-message-user .mmyww-ai-companion-widget-message-bubble {
    border-bottom-right-radius: 5px;
    background: #e8f1ff;
    color: #172554;
}

.mmyww-ai-companion-widget-message-assistant .mmyww-ai-companion-widget-message-bubble {
    border-bottom-left-radius: 5px;
    background: #fff0f6;
    color: #3f2636;
}

.mmyww-ai-companion-widget-typing {
    color: #6b7280;
    font-style: italic;
}

.mmyww-ai-companion-widget-typing .mmyww-ai-companion-widget-message-bubble {
    background: #f9fafb;
    color: #6b7280;
}

.mmyww-ai-companion-widget-message-sender {
    margin-bottom: 3px;
    font-size: 12px;
    font-weight: 800;
}

.mmyww-ai-companion-widget-message-text {
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.65;
}

.mmyww-ai-companion-widget-form {
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #f4e8f1;
    background: #fff;
}

.mmyww-ai-companion-widget-textarea {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 44px;
    max-height: 96px;
    padding: 9px 10px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    resize: vertical;
    font-size: 14px;
    line-height: 1.55;
}

.mmyww-ai-companion-widget-textarea:focus-visible,
.mmyww-ai-companion-widget-send:focus-visible,
.mmyww-ai-companion-widget-back:focus-visible,
.mmyww-ai-companion-widget-new-story:focus-visible,
.mmyww-ai-companion-widget-close:focus-visible,
.mmyww-ai-companion-widget-age-confirm-button:focus-visible,
.mmyww-ai-companion-widget-age-cancel-button:focus-visible {
    outline: 2px solid rgba(255, 77, 147, 0.45);
    outline-offset: 2px;
}

.mmyww-ai-companion-widget-send {
    flex: 0 0 auto;
    min-width: 70px;
    min-height: 44px;
    padding: 0 14px;
    border: 0;
    border-radius: 10px;
    background: #ff4d93;
    color: #fff;
    cursor: pointer;
    font-weight: 800;
}

.mmyww-ai-companion-widget-send:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

body.mmyww-ai-companion-widget-open {
    overflow: hidden;
}

body.modal-open .mmyww-ai-companion-widget-entry,
body.modal-open .mmyww-ai-companion-widget-panel,
.mmyww-ai-companion-widget-hidden .mmyww-ai-companion-widget-entry,
.mmyww-ai-companion-widget-hidden .mmyww-ai-companion-widget-panel {
    display: none !important;
}

@media (prefers-reduced-motion: reduce) {
    .mmyww-ai-companion-widget-entry,
    .mmyww-ai-companion-widget-panel {
        animation: none;
        transition: none;
        transform: none;
    }
}

@media (max-width: 640px) {
    .mmyww-ai-companion-widget-entry {
        right: 12px;
        bottom: calc(76px + env(safe-area-inset-bottom, 0px));
        min-width: 88px;
        min-height: 44px;
        padding: 0 12px;
        font-size: 13px;
        animation-name: mmyww-ai-companion-widget-float-mobile;
        animation-duration: 5.6s;
    }

    .mmyww-ai-companion-widget-panel {
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        max-height: 90vh;
        max-height: 90dvh;
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 16px 16px 0 0;
    }

    .mmyww-ai-companion-widget-body {
        display: flex;
        flex-direction: column;
        max-height: calc(90vh - 61px);
        max-height: calc(90dvh - 61px);
        padding: 10px;
    }

    .mmyww-ai-companion-widget-character-list {
        max-height: calc(90vh - 150px);
        max-height: calc(90dvh - 150px);
    }

    .mmyww-ai-companion-widget-messages {
        flex: 1 1 auto;
        min-height: 220px;
        max-height: calc(90vh - 300px);
        max-height: calc(90dvh - 300px);
    }

    .mmyww-ai-companion-widget-form {
        position: sticky;
        bottom: 0;
        flex-direction: column;
        margin-right: -10px;
        margin-bottom: -10px;
        margin-left: -10px;
        padding: 10px;
    }

    .mmyww-ai-companion-widget-textarea {
        width: 100%;
        min-height: 76px;
        font-size: 16px;
    }

    .mmyww-ai-companion-widget-send {
        width: 100%;
        min-height: 44px;
    }

    .mmyww-ai-companion-widget-message-bubble {
        max-width: calc(100% - 48px);
    }

    .mmyww-ai-companion-widget-age-dialog {
        align-items: flex-end;
        padding: 12px;
    }

    .mmyww-ai-companion-widget-age-dialog-box {
        width: 100%;
    }
}

@keyframes mmyww-ai-companion-widget-float-mobile {
    0%,
    100% {
        transform: translate3d(0, 0, 0) scale(1);
        box-shadow: 0 12px 28px rgba(139, 92, 246, 0.24);
    }

    50% {
        transform: translate3d(0, -4px, 0) scale(1.01);
        box-shadow: 0 14px 32px rgba(255, 77, 147, 0.24);
    }
}

@media (max-width: 640px) and (max-height: 700px) {
    .mmyww-ai-companion-widget-panel {
        max-height: 92vh;
        max-height: 92dvh;
    }

    .mmyww-ai-companion-widget-body {
        max-height: calc(92vh - 61px);
        max-height: calc(92dvh - 61px);
    }

    .mmyww-ai-companion-widget-messages {
        min-height: 170px;
        max-height: calc(92vh - 270px);
        max-height: calc(92dvh - 270px);
    }
}
