/* ==========================================================================
   全能小8 (Omni8 AI Agent) 完整樣式檔
   整合項目：
   1. 右下角動態公仔 (10格 1280x128: 待機循環 + Hover揮手)
   2. 頭頂不定時冷知識對話氣泡
   3. 對話主視窗容器 (支援自然柔和綠底漸層)
   4. 全視窗落葉/櫻花花瓣飄落穿透層 (自然S型擺盪+翻轉)
   5. 視窗標題列 (Header)
   6. 內容捲動區 (Body) 與 頂部小8純懸浮形象
   7. 全新對話訊息串流 (圓形頭像、時間戳、小8奶綠氣泡與使用者淡藍氣泡)
   8. 底部輸入列與附加選單 (Footer & Attach Menu)
   9. 圖片上傳預覽卡片與確認對話框樣式
   ========================================================================== */

/* --------------------------------------------------
   1. 右下角懸浮動態按鈕 (FAB)
   -------------------------------------------------- */
.agent-fab-btn {
    position: fixed !important;
    bottom: 25px !important;
    right: 25px !important;
    width: 128px !important;
    height: 128px !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer;
    z-index: 9999;
    user-select: none;
    display: block !important;
    overflow: visible !important;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.agent-fab-btn:hover {
    transform: scale(1.08) translateY(-4px);
}

/* 128x128 精靈圖 (10格: 128px * 10 = 1280px) */
.agent-sprite-avatar {
    width: 128px !important;
    height: 128px !important;
    display: block !important;
    background-image: url('/images/chat_btn_004.png');
    background-repeat: no-repeat;
    background-position: 0 0;
    background-size: 1280px 128px !important;
    pointer-events: none;
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.28));

    /* 待機狀態：1.8s 播放第 1~6 格，其餘時間靜止待機，週期 11.8s */
    animation: qq8IdleLoop 11.8s infinite !important;
}

@keyframes qq8IdleLoop {
    0% {
        background-position: 0 0;
        animation-timing-function: steps(6);
    }
    15.25% {
        background-position: -768px 0;
    }
    15.26% {
        background-position: 0 0;
    }
    100% {
        background-position: 0 0;
    }
}

/* 滑鼠 Hover：切換為第 7~10 格揮手動作 (4格: -768px 到 -1280px) */
.agent-fab-btn:hover .agent-sprite-avatar {
    animation: qq8WaveHands 0.6s steps(4) infinite !important;
}

@keyframes qq8WaveHands {
    from {
        background-position: -768px 0;
    }
    to {
        background-position: -1280px 0;
    }
}

/* 在線綠色指示燈 */
.agent-online-dot {
    position: absolute;
    bottom: 12px;
    right: 18px;
    width: 14px;
    height: 14px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    z-index: 2;
}

/* --------------------------------------------------
   2. 懸浮公仔頭頂的不定時說話氣泡
   -------------------------------------------------- */
.agent-speech-bubble {
    position: absolute;
    bottom: 125px;
    right: 15px;
    background: #ffffff;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.45;
    padding: 9px 14px;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
    border: 1.5px solid #ede7f6;
    max-width: 190px;
    min-width: 130px;
    text-align: left;
    white-space: normal;
    pointer-events: none;
    opacity: 0;
    transform: translateY(10px) scale(0.9);
    transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10000;
}

.agent-speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 32px;
    width: 12px;
    height: 12px;
    background: #ffffff;
    border-right: 1.5px solid #ede7f6;
    border-bottom: 1.5px solid #ede7f6;
    transform: rotate(45deg);
}

.agent-speech-bubble.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* --------------------------------------------------
   3. 對話主視窗容器 (Chat Window)
   -------------------------------------------------- */
.agent-window {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 440px;
    height: 660px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 60px);
    background: #ffffff linear-gradient(180deg, #ffffff 82%, #f0fdf4 100%) !important;
    border-radius: 24px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.16);
    border: 1px solid rgba(226, 232, 240, 0.8);
    display: none; /* 預設收合，由 JS 切換為 flex */
    flex-direction: column;
    z-index: 10000;
    overflow: hidden;
    animation: agentWindowSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes agentWindowSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* 展開放大模式 */
.agent-window.is-expanded {
    width: 620px;
    height: 820px;
}

/* --------------------------------------------------
   4. 全視窗飄落落葉/櫻花花瓣 (穿透層)
   -------------------------------------------------- */
.leaf-fall-global {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none !important;
    overflow: hidden;
    z-index: 10005;
}

.falling-leaf {
    position: absolute;
    top: -30px;
    background-repeat: no-repeat;
    background-size: contain;
    pointer-events: none;
    will-change: transform, opacity;
    animation: leafSwayDown linear forwards;
}

/* 自然落葉飄蕩軌跡：S 型擺動 + 3D 翻轉 */
@keyframes leafSwayDown {
    0% {
        transform: translate(0, 0) rotate(0deg) rotateY(0deg) scale(0.9);
        opacity: 0;
    }
    10% {
        opacity: 0.9;
    }
    25% {
        transform: translate(35px, 160px) rotate(45deg) rotateY(180deg) scale(0.95);
    }
    50% {
        transform: translate(-30px, 340px) rotate(-35deg) rotateY(360deg) scale(0.9);
    }
    75% {
        transform: translate(40px, 520px) rotate(60deg) rotateY(540deg) scale(0.85);
        opacity: 0.8;
    }
    100% {
        transform: translate(-15px, 700px) rotate(120deg) rotateY(720deg) scale(0.7);
        opacity: 0;
    }
}

/* --------------------------------------------------
   5. 視窗標題列 (Header)
   -------------------------------------------------- */
.agent-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    z-index: 10;
}

.agent-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 800;
    color: #0f172a;
}

.agent-status-tag {
    font-size: 13px;
    font-weight: 700;
    color: #16a34a;
    display: inline-flex;
    align-items: center;
}

.agent-window-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.agent-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.agent-icon-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
}

/* --------------------------------------------------
   6. 內容捲動區 (Body) 與 頂部小8純懸浮形象
   -------------------------------------------------- */
.agent-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: transparent !important;
}

/* 頂部 Hero：純懸浮透明卡片 */
.agent-hero-card {
    position: relative;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 10px 10px 0 0;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
    overflow: visible !important;
}

/* 🐝 小8 飛行舞台：放大至 140px，往上往外突出 */
.agent-fly-stage {
    position: relative;
    width: 140px;
    height: 140px;
    margin-top: -30px;
    margin-left: -10px;
    margin-bottom: -15px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    overflow: visible;
}

/* 8 款飛行造型精靈圖 (單格 140x140，8格總寬 1120px) */
.agent-fly-avatar {
    width: 140px !important;
    height: 140px !important;
    background-image: url('/images/140_chat_fly8_003.png');
    background-repeat: no-repeat;
    background-position: 0 0;
    background-size: 1400px 140px !important;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.18));
    transition: opacity 0.3s ease;
    animation: qq8HoverFloat 4.2s ease-in-out infinite alternate;
}

@keyframes qq8HoverFloat {
    0%   { transform: translate(0, 0) rotate(0deg); }
    25%  { transform: translate(4px, -6px) rotate(1.5deg); }
    50%  { transform: translate(-4px, -10px) rotate(-2deg); }
    75%  { transform: translate(-5px, -4px) rotate(1deg); }
    100% { transform: translate(3px, -8px) rotate(-0.5deg); }
}

/* 💬 頂部精緻白色對話氣泡 */
.agent-speech-bubble-hero {
    position: relative;
    background: #fef9e5;
    border: 1.5px solid #fee49b;
    border-radius: 18px;
    padding: 12px 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
    z-index: 5;
    flex: 1;
}

.agent-speech-bubble-hero::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -7px;
    transform: translateY(-50%) rotate(45deg);
    width: 12px;
    height: 12px;
    background: #fef9e5;
    border-left: 1.5px solid #fee49b;
    border-bottom: 1.5px solid #fee49b;
}

.hero-bubble-title {
    font-size: 14px;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 4px;
}

.hero-bubble-sub {
    font-size: 12.5px;
    color: #64748b;
    line-height: 1.45;
    font-weight: 500;
}

/* ==========================================================================
   7. 全新對話訊息串流 (圓形頭像、時間戳與精確配色)
   ========================================================================== */

/* 訊息外層列表 */
#agentMsgThread {
    display: flex !important;
    flex-direction: column !important;
    gap: 18px !important;
    padding: 8px 4px !important;
}

/* 單條訊息列（頭像 + 氣泡包裹層） */
.chat-msg-row {
    display: flex !important;
    align-items: flex-start !important;
    gap: 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    animation: chatMsgFadeIn 0.25s ease-out forwards;
}

@keyframes chatMsgFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 👈 小8（靠左排版） */
.chat-msg-row.agent {
    flex-direction: row !important;
}

/* 👉 使用者（靠右倒序排版） */
.chat-msg-row.user {
    flex-direction: row-reverse !important;
}

/* 圓形頭像外框 */
.chat-avatar {
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08) !important;
}

/* 小8蜜蜂頭像 (/images/omni8.png) */
.chat-avatar.agent {
    background: #ffffff !important;
    border: 1.5px solid #dcfce7 !important;
    padding: 2px !important;
}

.chat-avatar.agent img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    border-radius: 50% !important;
}

/* 使用者頭像基本容器 */
.chat-avatar.user {
    background: #90caf9 !important;
    color: #1976d2 !important;
    font-size: 20px !important;
    overflow: hidden !important; /* 💡 避免使用者方型照片溢出圓圈 */
}

/* 💡 使用者 Google 照片頭像 */
.chat-avatar.user img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    display: block !important;
}

/* 訊息氣泡與時間戳包裹區 */
.chat-msg-wrapper {
    display: flex !important;
    flex-direction: column !important;
    max-width: calc(100% - 75px) !important;
}

.chat-msg-row.agent .chat-msg-wrapper {
    align-items: flex-start !important;
}

.chat-msg-row.user .chat-msg-wrapper {
    align-items: flex-end !important;
}

/* 氣泡本體通用設定 */
.chat-msg-bubble {
    padding: 12px 18px !important;
    font-size: 14.5px !important;
    line-height: 1.65 !important;
    word-break: break-word !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03) !important;
    box-sizing: border-box !important;
}

/* 👈 小8氣泡：極淺柔和奶綠色、深色文字、左上微角 */
.chat-msg-row.agent .chat-msg-bubble {
    background: #f8faf8 !important;
    color: #27272a !important;
    border: 1.5px solid #e2ece2 !important;
    border-radius: 4px 22px 22px 22px !important;
}

/* 👉 使用者氣泡：柔和淡粉藍底、深藍文字、右上微角 */
.chat-msg-row.user .chat-msg-bubble {
    background: #e3f2fd !important;
    color: #1565c0 !important;
    border: 1px solid #bbdefb !important;
    border-radius: 22px 4px 22px 22px !important;
    font-weight: 500 !important;
}

/* 時間戳記 */
.chat-msg-time {
    font-size: 11px !important;
    color: #94a3b8 !important;
    margin-top: 5px !important;
    padding: 0 4px !important;
    user-select: none !important;
}

/* 對話內部段落排版 */
.chat-msg-bubble p {
    margin: 0 0 8px 0 !important;
    line-height: 1.65 !important;
}

.chat-msg-bubble p:last-child {
    margin-bottom: 0 !important;
}

.chat-msg-bubble ol,
.chat-msg-bubble ul {
    margin: 6px 0 10px 0 !important;
    padding-left: 20px !important;
}

.chat-msg-bubble li {
    margin-bottom: 4px !important;
    line-height: 1.55 !important;
}

.chat-msg-bubble strong,
.chat-msg-bubble b {
    color: #0f172a !important;
    font-weight: 700 !important;
}

/* --------------------------------------------------
   8. 底部輸入列與附加選單 (Footer & Attach Menu)
   -------------------------------------------------- */
.agent-footer {
    position: relative;
    padding: 10px 16px 14px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.03);
    z-index: 30;
}

/* 📎 點擊 + 號浮起的選單 */
.agent-attach-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 16px;
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 14px;
    padding: 6px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
    min-width: 210px;
    z-index: 100;
    display: none;
    opacity: 0;
    transform: translateY(8px) scale(0.96);
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.agent-attach-menu.is-open,
.agent-attach-menu.active {
    display: flex !important;
    flex-direction: column;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* 上傳生態照片選項 */
.agent-attach-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.18s ease;
    user-select: none;
}

.agent-attach-item:hover {
    background: #f1f5f9;
}

.agent-attach-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #eef2ff;
    color: #4f46e5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}

.attach-main-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
}

/* 圓弧外框膠囊輸入列 */
.agent-input-container {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1.5px solid #cbd5e1;
    border-radius: 999px;
    padding: 4px 6px 4px 10px;
    gap: 8px;
    transition: all 0.2s ease;
}

.agent-input-container:focus-within {
    border-color: #3b82f6;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ＋ 號按鈕 */
.agent-plus-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.agent-plus-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
    transform: rotate(90deg);
}

/* 輸入框 */
.agent-input-box {
    flex: 1;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    font-size: 14px;
    color: #1e293b;
    padding: 8px 4px;
}

.agent-input-box::placeholder {
    color: #94a3b8;
}

/* 送出圓鈕 */
.agent-send-button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #2563eb;
    border: none;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.15s ease, background 0.2s ease;
}

.agent-send-button:hover {
    background: #1d4ed8;
    transform: scale(1.06);
}

/* 底部小草免責宣告 */
.agent-disclaimer {
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 11px;
    color: #94a3b8;
}

/* 小8 對話框內切換物種提示 (簡約居中，不帶大頭像) */
.agent-switch-notice-wrap {
    display: flex;
    justify-content: center;
    margin: 8px 0;
    width: 100%;
}

.agent-switch-notice-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 12px;
    padding: 3px 12px;
    border-radius: 14px;
    border: 1px solid #e2e8f0;
}

.agent-switch-notice-pill b {
    color: #334155;
}

/* --------------------------------------------------
   9. 圖片上傳預覽卡片與確認對話框樣式
   -------------------------------------------------- */
.agent-msg-thread img,
.chat-msg-bubble img {
    display: block !important;
    max-width: 100% !important;
    max-height: 180px !important;
    width: auto !important;
    height: auto !important;
    object-fit: cover !important;
    border-radius: 12px !important;
    margin: 6px 0 10px 0 !important;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12) !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
}

.agent-confirm-actions {
    display: flex !important;
    gap: 10px !important;
    margin-top: 10px !important;
    width: 100% !important;
}

.agent-confirm-actions button,
.agent-btn-confirm {
    flex: 1 !important;
    padding: 8px 0 !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    border: none !important;
    transition: all 0.15s ease !important;
}

/* 是（確認辨識）按鈕 */
.agent-btn-confirm.yes {
    background: #2563eb !important;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25) !important;
}

.agent-btn-confirm.yes:hover {
    background: #1d4ed8 !important;
}

/* 否（取消）按鈕 */
.agent-btn-confirm.no {
    background: #f1f5f9 !important;
    color: #64748b !important;
    border: 1px solid #e2e8f0 !important;
}

.agent-btn-confirm.no:hover {
    background: #e2e8f0 !important;
}


/* 簡約置中切換提示 */
.agent-switch-notice {
    text-align: center;
    font-size: 12px;
    color: #64748b;
    margin: 8px auto;
    padding: 3px 12px;
    background: #f1f5f9;
    border-radius: 12px;
    width: fit-content;
}
.agent-switch-notice strong {
    color: #334155;
}


/* 小8 決策雙按鈕容器 */
.agent-choice-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.agent-choice-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

/* 聊聊按鈕：柔和天藍 */
.agent-choice-btn.btn-chat {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}
.agent-choice-btn.btn-chat:hover {
    background: #dbeafe;
    transform: translateY(-1px);
}

/* 辨識按鈕：質感亮紫 */
.agent-choice-btn.btn-identify {
    background: #6347d1;
    color: #ffffff;
}
.agent-choice-btn.btn-identify:hover {
    background: #5134A5;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(99, 71, 209, 0.3);
}

.agent-voice-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #64748b;
    padding: 4px 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.agent-voice-btn:hover {
    color: #0284c7;
    background: #f0f9ff;
}

/* 播放中動態效果 */
.agent-voice-btn.is-playing {
    color: #0284c7;
    animation: voice-pulse 1.2s infinite ease-in-out;
}

@keyframes voice-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.agent-inline-action-btn {
    color: #2563eb !important;       /* 科技藍 */
    font-weight: 600;
    text-decoration: underline wavy #93c5fd 1.5px !important; /* 波浪狀精緻底線 */
    text-underline-offset: 3px;
    padding: 0 2px;
    cursor: pointer;
    transition: color 0.15s ease;
}

.agent-inline-action-btn:hover {
    color: #1d4ed8 !important;
    text-decoration-color: #2563eb !important;
    background-color: #eff6ff;
    border-radius: 4px;
}
/* =========================================================
   手機版小 8 對話窗自適應修正 (iOS Safari 瀏海與工具列適配)
   ========================================================= */
@media (max-width: 768px) {
    /* 懸浮大圓角卡片視窗 */
#agentChatWindow,
    .agent-window {
        display: none !important;
        position: fixed !important;
        top: calc(env(safe-area-inset-top, 0px) + 12px) !important;
        bottom: calc(env(safe-area-inset-bottom, 0px) + 12px) !important;
        left: 14px !important;
        right: 14px !important;
        width: auto !important;
        max-width: calc(100vw - 28px) !important;
        height: auto !important;
        border-radius: 24px !important;
        background: #ffffff !important;
        border: 1px solid rgba(0, 0, 0, 0.08) !important;
        box-shadow: 0 12px 36px rgba(0, 0, 0, 0.22) !important;
        overflow: hidden !important;
        z-index: 99999 !important;
        flex-direction: column !important;
    }
    
    /* 只有在手動點擊觸發、被加上 is-active 或 style="display: flex" 時才開啟 */
    #agentChatWindow.is-active,
    #agentChatWindow[style*="display: flex"] {
        display: flex !important;
    }
    
    /* 只有在開啟時才顯示 flex */
    #agentChatWindow:not([style*="display: none"]),
    .agent-window.is-active {
        display: flex !important;
    }

    #agentChatWindow[style*="display: none"] {
        display: none !important;
    }

    /* 頂部標題列：高度固定、不用再額外墊大的 padding-top */
    #agentChatWindow .chat-header,
    #agentChatWindow .agent-header {
        flex-shrink: 0 !important;
        height: 52px !important;
        padding: 0 18px !important;
        background: #ffffff !important;
        border-bottom: 1px solid #f1f5f9 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        border-radius: 24px 24px 0 0 !important;
    }

    /* 對話內容區：維持順暢滾動 */
    #agentChatWindow .chat-messages-body,
    #agentChatWindow .chat-body {
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        padding: 16px !important;
    }

    /* 底部輸入列 */
    #agentChatWindow .chat-input-container,
    #agentChatWindow .chat-footer {
        flex-shrink: 0 !important;
        padding: 10px 14px 12px 14px !important;
        background: #ffffff !important;
        border-top: 1px solid #f8fafc !important;
        border-radius: 0 0 24px 24px !important;
    }
}