@charset "utf-8";

.top-ai-chat {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1000;
    font-family: inherit;
}

.top-ai-chat-toggle {
    width: 112px;
    height: 44px;
    color: #fff;
    font: inherit;
    font-size: 1.4rem;
    font-weight: bold;
    border: none;
    border-radius: 999px;
    background: #6F8D76;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    cursor: pointer;
}

.top-ai-chat-toggle.is-open {
    width: 48px;
    height: 48px;
    font-size: 0;
    border-radius: 50%;
}

.top-ai-chat-toggle.is-open::before {
    content: "×";
    font-size: 2.6rem;
    line-height: 1;
}

.top-ai-chat-window {
    position: absolute;
    right: 0;
    bottom: 60px;
    display: flex;
    flex-direction: column;
    width: min(384px, calc(100vw - 24px));
    height: min(640px, calc(100vh - 96px));
    overflow: hidden;
    background: #fff;
    border: 1px solid rgba(74, 59, 50, 0.12);
    border-radius: 8px;
    box-shadow: 0 12px 30px rgba(74, 59, 50, 0.22);
}

.top-ai-chat-window[hidden] {
    display: none;
}

.top-ai-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 54px;
    padding: 0 16px 0 18px;
    color: #fff;
    background: #6F8D76;
}

.top-ai-chat-head p {
    margin: 0;
    font-size: 1.5rem;
    font-weight: bold;
}

.top-ai-chat-head button {
    width: 36px;
    height: 36px;
    color: #fff;
    font-size: 2.4rem;
    line-height: 1;
    border: none;
    background: transparent;
    cursor: pointer;
}

.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;
}

.top-ai-chat .ai-chat-log {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
    padding: 18px;
    overflow-y: auto;
    background: #F5F3EB;
}

.top-ai-chat .ai-chat-message {
    max-width: 88%;
    padding: 12px 14px;
    border-radius: 8px;
}

.top-ai-chat .ai-chat-message p {
    margin: 0;
    color: #4A3B32;
    font-size: 1.45rem;
    line-height: 1.8;
    white-space: pre-wrap;
}

.top-ai-chat .ai-chat-message a {
    color: #6F8D76;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.top-ai-chat .ai-chat-message a:hover {
    color: #E07A5F;
}

.top-ai-chat .ai-chat-message-loading p {
    color: #6F8D76;
}

.top-ai-chat .ai-chat-message-user {
    align-self: flex-end;
    background: #DDE8DE;
}

.top-ai-chat .ai-chat-message-bot {
    align-self: flex-start;
    background: #fffef9;
    border: 1px solid rgba(74, 59, 50, 0.1);
}

.top-ai-chat .ai-chat-message-error {
    background: #FFF1EC;
}

.top-ai-chat .ai-chat-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 12px;
    background: #fffef9;
    border-top: 1px solid rgba(74, 59, 50, 0.12);
}

.top-ai-chat .ai-chat-form textarea {
    min-height: 50px;
    max-height: 140px;
    padding: 12px 14px;
    resize: vertical;
    color: #4A3B32;
    font: inherit;
    font-size: 1.4rem;
    line-height: 1.6;
    border: 1px solid rgba(74, 59, 50, 0.18);
    border-radius: 8px;
    background: #fff;
}

.top-ai-chat .ai-chat-form button {
    min-width: 72px;
    padding: 0 16px;
    color: #fff;
    font: inherit;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    background: #6F8D76;
    cursor: pointer;
}

.top-ai-chat .ai-chat-form button:disabled {
    cursor: wait;
    opacity: 0.7;
}

@media (max-width: 420px) {
    .top-ai-chat {
        right: 12px;
        bottom: 12px;
    }

    .top-ai-chat-window {
        bottom: 58px;
        width: calc(100vw - 24px);
        height: min(620px, calc(100vh - 86px));
    }

    .top-ai-chat .ai-chat-form {
        grid-template-columns: 1fr;
    }

    .top-ai-chat .ai-chat-form button {
        min-height: 44px;
    }
}
