/* ===== 右下角卡通 AI 形象（纯本地，无外部资源） ===== */
.ai-avatar {
    position: fixed;
    right: 18px;
    bottom: 24px;
    width: 76px;
    height: 76px;
    z-index: 960;
    cursor: pointer;
    animation: aiFloat 4.2s ease-in-out infinite;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.ai-avatar:hover { transform: scale(1.06); }

.ai-avatar-body {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    animation: aiBreathe 2.6s ease-in-out infinite;
}

/* batch21 ①：外部 AI 形象（<img>）按容器自适应，保持视觉协调 */
.ai-avatar img.ai-avatar-body {
    object-fit: contain;
    border-radius: 16px;
    width: 100%;
    height: 100%;
}

/* 底部光晕 */
.ai-avatar::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -4px;
    width: 46px;
    height: 12px;
    transform: translateX(-50%);
    background: radial-gradient(ellipse at center, rgba(255, 200, 90, .55), transparent 70%);
    border-radius: 50%;
    animation: aiGlow 2.6s ease-in-out infinite;
}

/* 星星粒子 */
.ai-avatar-spark {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: radial-gradient(circle, #fff 20%, #ffe08a 55%, transparent 70%);
    border-radius: 50%;
    animation: aiSpark 3.2s ease-in-out infinite;
    z-index: 2;
}

@keyframes aiFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
@keyframes aiBreathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}
@keyframes aiGlow {
    0%, 100% { opacity: .5; transform: translateX(-50%) scale(1); }
    50% { opacity: .95; transform: translateX(-50%) scale(1.18); }
}
@keyframes aiSpark {
    0%, 100% { opacity: .4; transform: scale(.8) rotate(0deg); }
    50% { opacity: 1; transform: scale(1.25) rotate(20deg); }
}

/* ===== 聊天面板 ===== */
.ai-chat {
    position: fixed;
    right: 18px;
    bottom: 112px;
    width: 348px;
    max-width: calc(100vw - 28px);
    height: 480px;
    max-height: calc(100vh - 150px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 970;
    border: 1px solid #f0e2c6;
    animation: aiPanelIn .22s ease-out;
}
.ai-chat[hidden] { display: none; }

@keyframes aiPanelIn {
    from { opacity: 0; transform: translateY(14px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.ai-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: linear-gradient(135deg, #ffd966, #ffb13d);
    color: #5a3400;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}
.ai-chat-close {
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, .45);
    font-size: 13px;
    line-height: 1;
}
.ai-chat-close:hover { background: rgba(255, 255, 255, .8); }

.ai-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    background: #fffdf7;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-msg {
    display: flex;
    max-width: 92%;
    align-items: flex-end;
}
.ai-msg-bot { align-self: flex-start; }
.ai-msg-user { align-self: flex-end; }

.ai-msg-bubble {
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap;
}
.ai-msg-bot .ai-msg-bubble {
    background: #fff;
    border: 1px solid #f0e2c6;
    border-bottom-left-radius: 4px;
    color: #3a3a3a;
}
.ai-msg-user .ai-msg-bubble {
    background: linear-gradient(135deg, #ffb13d, #ff8f2e);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ai-msg-link {
    display: inline-block;
    margin-top: 6px;
    color: #e8590c;
    text-decoration: underline;
    word-break: break-all;
}
.ai-msg-btn {
    display: inline-block;
    margin-top: 6px;
    padding: 5px 12px;
    border-radius: 8px;
    background: linear-gradient(135deg, #ffb13d, #ff8f2e);
    color: #fff;
    font-size: 12.5px;
    text-decoration: none;
}
.ai-msg-btn.ghost {
    background: #fff;
    color: #e8590c;
    border: 1px solid #ffc48a;
}

.ai-chat-input {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #f2e8d6;
    background: #fff;
    flex-shrink: 0;
}
.ai-chat-input textarea {
    flex: 1;
    border: 1px solid #e5dcc8;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 13.5px;
    font-family: inherit;
    resize: none;
    line-height: 1.5;
    max-height: 88px;
    outline: none;
    background: #fffdf8;
}
.ai-chat-input textarea:focus { border-color: #ffb13d; }
.ai-chat-input button {
    border: none;
    border-radius: 10px;
    padding: 20px 16px;
    background: linear-gradient(135deg, #ffb13d, #ff8f2e);
    color: #fff;
    font-size: 13.5px;
    cursor: pointer;
    flex-shrink: 0;
}
.ai-chat-input button:disabled { opacity: .55; cursor: not-allowed; }

.ai-msg-loading .ai-msg-bubble { color: #999; font-style: italic; }

/* 移动端：缩小头像、避开底部导航 */
@media (max-width: 640px) {
    .ai-avatar {
        right: 12px;
        bottom: 74px;
        width: 62px;
        height: 62px;
    }
    .ai-chat {
        right: 12px;
        bottom: 100px;
        height: 440px;
    }
}

/* ===== AI 快捷功能栏（输入框上方） ===== */
.ai-chat-quick {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 10px 4px;
    border-top: 1px solid #f3e3c8;
    background: #fffaf2;
}
.ai-quick-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px 10px;
    font-size: 12px;
    line-height: 1.5;
    color: #7a5a2e;
    background: #fff3dc;
    border: 1px solid #f0d9ab;
    border-radius: 999px;
    cursor: pointer;
    user-select: none;
    transition: all .15s;
}
.ai-quick-btn:hover { background: #ffe3ad; border-color: #e8b96a; color: #5a3c14; }
.ai-quick-btn[hidden] { display: none; }
.ai-quick-caret { font-size: 10px; opacity: .7; }
.ai-beauty-menu {
    position: absolute;
    left: 10px;
    bottom: 100%;
    z-index: 20;
    min-width: 150px;
    padding: 6px;
    background: #fff;
    border: 1px solid #f0d9ab;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(120, 80, 20, .14);
}
.ai-beauty-menu[hidden] { display: none; }
.ai-beauty-item {
    display: block;
    padding: 7px 10px;
    font-size: 13px;
    color: #5a3c14;
    border-radius: 7px;
    cursor: pointer;
}
.ai-beauty-item:hover { background: #fff3dc; }

/* ===== 快捷结果展示 ===== */
.ai-quick-title {
    font-weight: 600;
    color: #8a5a1a;
    margin-bottom: 6px;
    font-size: 13px;
}
.ai-kv {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
    line-height: 1.5;
}
.ai-kv-label { color: #333; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-kv-sub { color: #e8882e; white-space: nowrap; }
.ai-kv-desc { color: #888; font-size: 12px; margin: 2px 0; }
.ai-kv-time { color: #bbb; font-size: 11px; margin-bottom: 8px; }
.ai-acc-table { width: 100%; border-collapse: collapse; margin-top: 2px; }
.ai-acc-row { display: flex; gap: 6px; padding: 5px 4px; font-size: 12px; border-bottom: 1px dashed #f2e2c2; }
.ai-acc-head { font-weight: 600; color: #a06a20; border-bottom: 1px solid #e8c98a; }
.ai-acc-row > span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-dot { font-style: normal; }
.ai-dot.on { color: #2e9e44; }
.ai-dot.off { color: #bbb; }
.ai-days { font-style: normal; color: #c9a45c; font-size: 11px; margin-left: 3px; }

/* ===== 美女图片消息 ===== */
.ai-img-title { font-weight: 600; color: #8a5a1a; margin-bottom: 6px; font-size: 13px; }
.ai-img-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ai-img-cell { display: block; border-radius: 8px; overflow: hidden; background: #f7efe0; }
.ai-img-cell img { display: block; width: 100%; height: 72px; object-fit: cover; }

/* ===== 登录提示弹窗（可关闭，不自动跳转） ===== */
.ai-login-mask {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(80, 50, 10, .35);
    border-radius: 16px;
}
.ai-login-mask[hidden] { display: none; }
.ai-login-box {
    width: 78%;
    max-width: 240px;
    padding: 18px 16px 16px;
    background: #fff;
    border-radius: 14px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(60, 35, 5, .25);
}
.ai-login-title { font-size: 16px; font-weight: 700; color: #5a3c14; margin-bottom: 6px; }
.ai-login-tip { font-size: 12px; color: #999; line-height: 1.6; margin-bottom: 14px; }
.ai-login-actions { display: flex; gap: 8px; justify-content: center; }
.ai-login-btn {
    padding: 7px 16px;
    font-size: 13px;
    color: #fff;
    background: linear-gradient(135deg, #ffb13d, #ff8f2e);
    border-radius: 999px;
    text-decoration: none;
}
.ai-login-close {
    padding: 7px 16px;
    font-size: 13px;
    color: #7a5a2e;
    background: #fff3dc;
    border: 1px solid #f0d9ab;
    border-radius: 999px;
    cursor: pointer;
}

/* ===== AI 聊天气泡（batch27）：小精灵左侧展示，可关闭 ===== */
.ai-bubble {
    position: fixed;
    right: 104px;
    bottom: 30px;
    z-index: 950;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    max-width: 280px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #ffd9a8;
    border-radius: 14px 14px 2px 14px;
    box-shadow: 0 6px 18px rgba(225, 37, 27, .12);
    font-size: 13px;
    line-height: 1.6;
    color: #5a3c14;
}
.ai-bubble::before {
    content: '';
    position: absolute;
    right: -6px;
    bottom: 12px;
    width: 12px;
    height: 12px;
    background: #fff;
    border-right: 1px solid #ffd9a8;
    border-bottom: 1px solid #ffd9a8;
    transform: rotate(-45deg);
}
.ai-bubble-text { flex: 1; min-width: 0; word-break: break-word; transition: opacity .16s ease; }
.ai-bubble-text.ai-bubble-fade { opacity: 0; }
.ai-bubble-close {
    flex: none;
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    font-size: 12px;
    color: #c9a45c;
    background: #fff3dc;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
}
.ai-bubble-close:hover { background: #ffe3b3; color: #a06a20; }
.ai-bubble[hidden] { display: none; }
@media (max-width: 640px) {
    .ai-bubble {
        right: 84px;
        bottom: 78px;
        max-width: 220px;
    }
}
