html {
        scroll-behavior: smooth;
        scroll-padding-top: 4.5rem;
    }

    .gradient-text {
        background: linear-gradient(to right, #3b82f6, #06b6d4);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
    }
    .gradient-bg {
        background: linear-gradient(to right, #2563eb, #0891b2);
    }
    .gradient-bg-dark {
        background: linear-gradient(to bottom right, #111827, #1e3a8a, #111827);
    }
    .hover-scale {
        transition: transform 0.3s ease;
    }
    .hover-scale:hover {
        transform: scale(1.05);
    }

    @keyframes marqueeScroll {
        0% { transform: translateX(0%); }
        100% { transform: translateX(-50%); }
    }
    .marquee-inner {
        animation: marqueeScroll 35s linear infinite;
    }
    .marquee-inner:hover {
        animation-play-state: paused;
    }
    .marquee-reverse {
        animation-direction: reverse;
    }

/* Submit 按鈕基礎動畫 */
#submitBtn {
    transition: all 0.25s ease;
}

/* Hover：正常狀態（藍→青） */
#submitBtn:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 20px rgba(0,0,0,0.25);
}

/* Hover：錯誤狀態（紅） */
#submitBtn.error-hover:hover {
    background: linear-gradient(to right, #b91c1c, #dc2626) !important;
}

/* Hover：成功狀態（綠） */
#submitBtn.success-hover:hover {
    background: linear-gradient(to right, #15803d, #16a34a) !important;
}

/* 確保返回頂部按鈕擁有順暢的過渡動畫 */
#back-to-top {
  transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.2s ease;
}

/* --- 1. 右下角懸浮聊天按鈕 --- */
.chat-trigger-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    background-color: #007bff; /* 客服主題藍色 */
    color: white;
    border-radius: 50%;
    border: none;
    box-shadow: 0 4px 16px rgba(0, 123, 255, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    transition: transform 0.2s, background-color 0.2s;
    z-index: 9999;
}
.chat-trigger-btn:hover {
    background-color: #0056b3;
    transform: scale(1.05);
}

/* --- 2. 彈出對話視窗 --- */
.chat-window {
    position: fixed;
    bottom: 96px; /* 剛好在按鈕上方 */
    right: 24px;
    width: 360px;
    height: 500px;
    background-color: white;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    display: none; /* 預設隱藏 */
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    animation: slideUp 0.3s ease;
}

/* 視窗彈出動畫 */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- 3. 对话框顶部 (Header) --- */
.chat-header {
    background-color: #007bff;
    color: white;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.8;
}
.close-btn:hover {
    opacity: 1;
}

/* --- 4. 對話主體區 --- */
.chat-body {
    flex: 1;
    padding: 16px;
    background-color: #f8f9fa;
    overflow-y: auto;      /* 保持垂直滾動 */
    overflow-x: hidden;    /* 🔒 關鍵修正：從源頭徹底殺死任何橫向滑動條 */
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.welcome-box {
    margin-bottom: 12px;
    width: 100%;           /* 確保歡迎區外殼不超載 */
}

#chatMessages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;           /* 確保訊息容器鎖定寬度 */
}

/* --- 5. 底部輸入框 (Footer) --- */
.chat-footer {
    padding: 12px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
    background: white;
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
}
.chat-input:focus {
    border-color: #007bff;
}

.send-btn {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 0 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
}
.send-btn:hover {
    background-color: #0056b3;
}

/* ====== 訊息外層（控制左右） ====== */
.msg-wrap-user {
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* 訪客靠左 */
    margin: 8px 0;
    width: 100%;             /* 確保外層佔滿，內層才能計算 max-width */
}

.msg-wrap-admin {
    display: flex;
    flex-direction: column;
    align-items: flex-end;   /* 客服靠右 */
    margin: 8px 0;
    width: 100%;             /* 確保外層佔滿 */
}

/* ====== 訊息泡泡 ====== */
.msg-user {
    background: #007bff;
    color: white;
    padding: 8px 12px;
    border-radius: 10px;
    max-width: 75%;
    width: fit-content;      /* 🔒 關鍵修正：解決 Flex 佈局文字不換行的惡性 Bug */
    word-break: break-all;   /* 🔒 核心：任何英數、1111 碰到邊界立刻強制斷行 */
    white-space: pre-wrap;   /* 🔒 核心：支援換行符號 */
}

.msg-bot {
    background: #eaeaea;
    color: #333;
    padding: 8px 12px;
    border-radius: 10px;
    max-width: 75%;          
    width: fit-content;      
    word-break: break-all;   
    white-space: pre-wrap;   
}

/* ====== 🎯 唯獨將最頂部「固定歡迎區」的泡泡拉滿到 100% ====== */
.welcome-box .msg-bot {
    max-width: 100% !important; /* 🌟 只有最上方的歡迎詞會佔滿 100% 大氣版面 */
    width: 100% !important;     /* 🌟 強制填滿 100%，字再多都不會擁擠 */
    line-height: 1.5;           /* 增加舒適的行高 */
}

/* ====== ⏱️ 時間排版修正：精準貼合各自的泡泡下方 ====== */
.msg-time-right {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
    padding-left: 4px;
    align-self: flex-start;  /* 🔒 關鍵：強制訪客的時間貼著左邊（跟隨藍色泡泡） */
    text-align: left;
}

.msg-time-left {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
    padding-right: 4px;
    align-self: flex-end;    /* 🔒 關鍵：強制管理員的時間貼著右邊（跟隨灰色泡泡） */
    text-align: right;
}

/* ====== 左邊訊息（Admin）動畫 ====== */
@keyframes slideLeft {
    0% { opacity: 0; transform: translateX(-12px); }
    100% { opacity: 1; transform: translateX(0); }
}

/* ====== 右邊訊息（User）動畫 ====== */
@keyframes slideRight {
    0% { opacity: 0; transform: translateX(12px); }
    100% { opacity: 1; transform: translateX(0); }
}

.msg-anim-right {
    animation: slideRight 0.25s ease-out;
    animation-fill-mode: both;
}

.msg-anim-left {
    animation: slideLeft 0.25s ease-out;
    animation-fill-mode: both;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.qa-btn {
    display: block;
    background: #f0f0f0;
    padding: 10px;
    text-align: center;
    border-radius: 6px;
    font-size: 14px;
    color: #333;
    text-decoration: none;
    border: 1px solid #ddd;
    transition: 0.2s;
}
.qa-btn:hover {
    background: #e6e6e6;
}

/* ==========================================
   汽車滾動特效 Banner 專用樣式
   ========================================== */

/* 滾動動畫軌道 */
.banner-scroll-track {
    height: 250vh; 
    position: relative;
}

/* 固定容器 */
.banner-sticky-container {
    position: sticky;
    top: 0;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 背景圖片 */
.banner-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('/images/bg.png'); 
    background-size: cover;
    background-position: center;
    z-index: 1;
}

/* 白色 Fade 上下遮罩 */
.banner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom, 
        rgba(255, 255, 255, 1) 0%, 
        rgba(255, 255, 255, 0.1) 25%, 
        rgba(255, 255, 255, 0.1) 75%, 
        rgba(255, 255, 255, 1) 100%
    );
    z-index: 2;
}

/* 暗黑模式動態適應遮罩 */
.dark .banner-overlay {
    background: linear-gradient(
        to bottom, 
        rgba(17, 24, 39, 1) 0%, 
        rgba(17, 24, 39, 0.1) 25%, 
        rgba(17, 24, 39, 0.1) 75%, 
        rgba(17, 24, 39, 1) 100%
    );
}

/* 🚗 1. 汽車包裝容器：由 JS 完美掌控 scale, translateX, translateY */
.car-wrapper {
    position: relative;
    z-index: 3;
    width: 85%;         
    max-width: 650px;   
    height: auto;
    
    transform-origin: center center; 
    /* 初始狀態 */
    transform: scale(0.4) translateX(0px) translateY(0px);  
    transition: transform 0.05s ease-out; 
    will-change: transform; 
}

/* 🚗 2. 汽車圖片本身：預設隱藏 */
.car-image {
    width: 100%;
    height: auto;
    display: block;
    
    opacity: 0;
    visibility: hidden;
    will-change: opacity; 
}

/* 🚗 3. 當滾動開始 (progress > 0) 觸發純淡入效果，不干擾位移 */
.car-wrapper.visible .car-image {
    opacity: 1;
    visibility: visible;
    /* 0.3秒內絲滑淡入 */
    animation: carFadeIn 0.3s ease-out forwards;
}

/* 🚗 4. 純淡入動畫定義 */
@keyframes carFadeIn {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

/* Banner 文字與按鈕容器定位 */
.banner-text-content {
    position: absolute;
    left: 8%;
    top: 20%; 
    z-index: 4;
    width: 84%;
    max-width: 600px;
    pointer-events: none;
}

/* 標題、內容與按鈕動畫基底 */
.banner-title, 
.banner-subtitle, 
.banner-bullets li,
.banner-btn {
    opacity: 0;
    transform: translateX(-40px);
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    font-weight: bold;
}

.banner-title {
    font-size: 3.4rem; 
    font-weight: 800;   
    color: #111111;
    margin-bottom: 15px;
    line-height: 1.2;
}

.dark .banner-title {
    color: #ffffff;
}

.banner-subtitle {
    font-size: 1.8rem;  
    color: #ffffff;     
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3); 
    margin-bottom: 25px;
    font-weight: 700;   
    line-height: 1.4;
}

.dark .banner-subtitle {
    color: #93c5fd;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.banner-bullets {
    list-style: none;
    padding: 0;
    margin-bottom: 25px;
}

.banner-bullets li {
    font-size: 1.25rem;
    color: #222222;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    font-weight: 700;   
    text-shadow: 0 1px 4px rgba(255, 255, 255, 0.8);
}

.dark .banner-bullets li {
    color: #e5e7eb;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

.banner-bullets li::before {
    content: "✓";
    color: #0071e3;
    font-weight: bold;
    margin-right: 10px;
}

/* 按鈕專用樣式 (青藍漸變與置中) */
.banner-btn {
    width: 100%;
    max-width: 340px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    text-decoration: none;
    pointer-events: auto;
    background: linear-gradient(135deg, #3b82f6 0%, #22d3ee 100%);
    box-shadow: 0 10px 25px rgba(34, 211, 238, 0.35);
}

.banner-btn:hover {
    background: linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
    box-shadow: 0 15px 30px rgba(34, 211, 238, 0.5);
}

/* 動態出現順序設定 */
.banner-text-content.active .banner-title {
    opacity: 1;
    transform: translateX(0);
    transition-delay: 0.1s;
}

.banner-text-content.active .banner-subtitle {
    opacity: 1;
    transform: translateX(0);
    transition-delay: 0.25s;
}

.banner-text-content.active .banner-bullets li:nth-child(1) {
    opacity: 1;
    transform: translateX(0);
    transition-delay: 0.4s;
}

.banner-text-content.active .banner-bullets li:nth-child(2) {
    opacity: 1;
    transform: translateX(0);
    transition-delay: 0.52s;
}

.banner-text-content.active .banner-bullets li:nth-child(3) {
    opacity: 1;
    transform: translateX(0);
    transition-delay: 0.64s;
}

.banner-text-content.active .banner-btn {
    opacity: 1;
    transform: translateX(0);
    transition-delay: 0.76s;
}

/* 📱 手機模式專屬：置中、控制寬度與純 CSS 斷行樣式 */
@media (max-width: 768px) {
    
    /* 1. 讓整體文字內容容器水平置中並內縮 */
    .banner-text-content {
        text-align: center;
        margin-left: auto;
        margin-right: auto;
        width: 90%;          /* 限制寬度避免貼邊 */
        display: flex;
        flex-direction: column;
        align-items: center; /* 確保內部 flex 子元素置中 */
    }

    /* 2. 正標題：純 CSS 強迫斷行與置中 */
    .banner-title {
        font-size: 0;        /* 隱藏原本 HTML 的單行文字 */
        line-height: 1.3;
        margin-bottom: 12px;
        text-align: center;
        width: 100%;
    }
    .banner-title::before {
        content: "中港澳跨境專車";
        font-size: 38px;     /* 請根據你原本的手機版標題大小調整 */
        display: block;
    }
    .banner-title::after {
        content: "貸款快線";
        font-size: 38px;     /* 請根據你原本的手機版標題大小調整 */
        display: block;
    }

    /* 3. 副標題：純 CSS 強迫斷行與置中 */
    .banner-subtitle {
        font-size: 0;        /* 隱藏原本 HTML 的單行文字 */
        line-height: 1.4;
        margin-bottom: 20px;
        text-align: center;
        width: 100%;
    }
    .banner-subtitle::before {
        content: "為跨境營運車輛";
        font-size: 26px;     /* 請根據你原本的手機版副標題大小調整 */
        display: block;
    }
    .banner-subtitle::after {
        content: "提供靈活貸款與還款期數";
        font-size: 26px;     /* 請根據你原本的手機版副標題大小調整 */
        display: block;
    }

    /* 4. 調整勾選列表的置中對齊 */
    .banner-bullets {
        text-align: left;    /* 保持文字左對齊以維持美觀 */
        display: inline-block;/* 轉為行內區塊以便在外層置中 */
        margin: 0 auto 20px auto; /* 上方不留白，左右自動置中，下方留間距 */
        padding-left: 20px;  /* 保留清單符號的縮進 */
    }

    /* 5. 按鈕寬度控制與置中 */
    .banner-btn {
        margin-left: auto;
        margin-right: auto;
        max-width: 320px;    /* 限制手機版按鈕最大寬度，避免過長 */
    }
}

/* 限制手機橫屏時，選單面板的最大高度，並允許內部垂直滾動 */
@media (max-width: 932px) and (orientation: landscape) {
  #mobile-menu {
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
  }
}
