/* =============================================================================
   1. 基礎佈局與全域樣式 (Global Settings)
   ============================================================================= */
html {
    overflow-x: hidden;
}

body {
    font-family: Arial, "Microsoft JhengHei", sans-serif;
    margin: 0;
    padding: 0;
    text-align: center;
    overflow-x: hidden;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: auto;
    text-size-adjust: 100%;
    background-color: #97dbfe;    
    min-height: 110vh !important;
}

/* 建立一個鎖定在螢幕上的背景層 */
body::before {
    content: "";
    position: fixed;
    /* 🚀 關鍵修正：改用四邊 0 鎖定，不要只用 width/height 100% */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    
    /* 🚀 關鍵修正：解決 iOS 工具列伸縮導致圖片跳動 */
    height: 100lvh; /* 使用 lvh (Large Viewport Height) 確保圖片涵蓋最大範圍 */
    
    background: url('images/cgmh20182.jpg');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    z-index: -1;
    
    /* 防止背景層攔截任何滑動手勢，讓滑動直接傳遞給 body */
    pointer-events: none; 
    
    /* 避免背景圖片在滾動時因為渲染順序產生抖動 */
    will-change: transform; 
}

/* 🚀 統一寬度與置中規則 */
header,
#scanner-section, 
.tabs, 
.selector {
    width: 92%;                      /* 使用百分比確保手機版適配 */
    max-width: 95%;     
    margin-left: auto !important;    /* auto 會自動平分左右空間，達成水平置中 */
    margin-right: auto !important;
    margin-top: 15px;
    margin-bottom: 15px;
    box-sizing: border-box;          /* 確保 Padding 不會撐破寬度 */
}

/* =============================================================================
   2. 頁首與統計顯示 (Header & Stats)
   ============================================================================= */
header {
    padding-top: env(safe-area-inset-top,30px); 
    padding-bottom: 15px; 
    padding-left:15px; 
    padding-right: 15px; 
    background: #2c7be5; 
    border: 1px solid #2c7be5; 
    border-radius: 20px; 
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.7); 
    color: white;
}

header h1 {
    margin-top: 10px; 
    margin-bottom: 5px; 
    font-size: 28px; 
    letter-spacing: 5px;
}

header p {
    margin-top: 0px; 
    margin-bottom: 10px; 
    font-size: 14px;
    letter-spacing: 1px;
}

/* 統計數據主容器 */
.stats-display {
    display: flex;
    flex-direction: column;
    align-items: flex-end; /* 右對齊 */
    font-size: 11px;
    color: #FFFF00;        /* 統一設定 Emoji 與文字顏色 */
    margin-top: 5px;
    padding-right: 5px;
    line-height: 1.8;
}

/* 統計數據每一行的佈局 */
.stats-row {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}

/* 針對統計項目中的文字與間距 */
.stats-display span {
    display: flex;
    align-items: center;
    white-space: nowrap;
    margin-left: 10px;
    gap: 4px;
}

/* 固定數字的寬度 */
.stat-value {
    display: inline-block;
    color: #FFFFFF;
    font-weight: bold;
    width: 35px;       /* 🚀 設定固定寬度，確保四位數內都不會撐開排版 */
    text-align: center; /* 數字在自己的區塊內置中 */
    margin: 0 4px;     /* 數字與前後圖案、文字的間距 */
}

/* 數據數字統一設為白色 */
.stats-display b {
    color: #FFFFFF;
    font-weight: bold;
}

/* =============================================================================
   3. 掃描辨識核心區塊 (Scanner Section)
   ============================================================================= */
#content {
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
}

/* 外層容器數據 */
#scanner-section {
    margin: 20px;
    padding: 15px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    position: relative;
}

.scanner-title {
    font-size: 24px;
    margin-top: 5px;
    margin-bottom: 15px;
}

/* 隱私宣告 */
.privacy-container {
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
    padding: 5px 10px;
    border-radius: 10px;
    margin-bottom: 12px;
    display: inline-block;
}
.privacy-text {
    font-size: 12px;
    color: #0056b3;
    margin: 0;
    line-height: 1.4;
}

/* 提示與導引按鈕 */
.guide-prompt-area {
    text-align: center;
    margin-top: -5px;
}
.guide-instruction {
    font-size: 14px;
    letter-spacing: 1px;
    color: #666;
    margin-bottom: 10px;
    font-weight: bold;
}
.btn-where-code {
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    color: #2c7be5;
    font-size: 12px;
    letter-spacing: 1px;
    cursor: pointer;
    padding: 4px 12px;
    margin-bottom: 10px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* 範例圖片彈窗 - 嚴格遵守原始定位數據 */
.guide-popup-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -55%);
    width: 85%;
    max-width: 320px;
    z-index: 9999;
    background: #f0f7ff;
    border: none;
    border-radius: 15px;
    padding: 0px 15px 15px 15px;
    text-align: center;
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}
.guide-popup-title {
    font-size: 15px;
    color: #2c7be5;
    margin-bottom: 10px;
    font-weight: bold;
}
.guide-img-frame {
    position: relative;
    border-radius: 8px;
    border: 1px solid #ccc;
    line-height: 0;
}
.guide-sample-img {
    width: 100%;
    display: block;
    border-radius: 8px;
    filter: brightness(0.7) contrast(1.4) saturate(1.1) sharpness(0.7);
}
.guide-popup-footer {
    margin-top: 12px;
}
.guide-popup-footer button {
    font-size: 12px;
    background: #2c7be5;
    color: #fff;
    border: none;
    border-radius: 15px;
    padding: 5px 15px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* =============================================================================
   4. 相機組件樣式 (Camera Component)
   ============================================================================= */
/* 相機容器 */
.camera-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 10px;
    background: #000;
}
#camera {
    width: 100%;
    height: 280px;
    object-fit: cover;
    display: none;
    background: #000;
}

/* 按鈕組數據 */
.camera-btn-group {
    margin-top: 15px;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 10px;
    width: 95%;
    max-width: 450px;
    margin-left: auto;
    margin-right: auto;
}

/* 相機按鈕文字 */
#btn-text {
    font-size: 16px ;
    color: #2c7be5 ;
    font-weight: bold;
    letter-spacing: 5px;
    padding-left: 5px;
    white-space: nowrap;
}

/* 辨識、暫停、返回按鈕的通用樣式 */
.camera-btn-group button:not(#start-cam-btn) {
    flex: 1 1 0;
    max-width: 140px;
    min-width: 0;
    height: 40px;
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
}

#scan-btn { background: #28a745; }
#stop-btn { background: #dc3545; }
#back-btn { background: #2c7be5; }

#scan-status { margin-top: 15px; font-weight: bold; }
#result { font-size: 11px; color: #999; word-break: break-all; opacity: 0.7; }

/* =============================================================================
   5. 頁尾語系導引 (Footer & Language Guide)
   ============================================================================= */
/* Footer 外層 */
.footer-container {
    margin-top: -5px;
    padding: 0px 10px;
    border-top: 1px solid #eee;
    text-align: center;
    background-color: #fcfcfccc;
    /* 字體設定完整還原 */
    font-family: -apple-system, system-ui, BlinkMacSystemFont, sans-serif;
}

/* 內容最大寬度限制 */
.footer-content {
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.6;
}

/* 標題：Language Guide */
.footer-lang-title {
    color: #333;
    font-weight: 700;
    margin-bottom: 10px;
    font-size: 16px;
    letter-spacing: 0.5px;
}

/* 語系操作細節文字顏色與字級 */
.footer-lang-details {
    color: #666;
    font-size: 13px;
    margin-bottom: 15px;
}

/* iPhone/Android 每一行的間距 */
.lang-item {
    margin-bottom: 4px;
}

/* 特殊按鈕圖示樣式 (如 AA, ≣) */
.key-cap {
    background: #eee;
    padding: 1px 5px;
    border-radius: 4px;
    font-weight: bold;
}

.key-icon {
    background: #eee;
    padding: 1px 3px;
    border-radius: 4px;
}

.key-bold {
    font-weight: bold;
}

/* 最後一行文字 */
.lang-last {
    /* 這裡維持預設，不加 margin-bottom */
}

/* 藍色 AI 提示區塊 */
.footer-ai-tip {
    color: #007AFF;
    font-weight: 600;
    margin: 0;
    font-size: 12px;
    padding: 8px 12px;
    background-color: #f0f7ff;
    border-radius: 12px;
    display: inline-block;
    max-width: 90%;
    /* 處理文字溢出不換行 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =============================================================================
   6. 分頁導覽系統 (Tabs Navigation)
   ============================================================================= */
.tabs {
    margin: 20px auto;                             /* 上下留 20px，auto 負責水平置中 */
    padding: 15px;
    background: transparent; 
    backdrop-filter: blur(5px); 
    -webkit-backdrop-filter: blur(5px);
    border-radius: 50px;                           /* 足夠大的圓角，創造膠囊感 */
    border: 1px solid #e0e0e0;                     /* 淡淡的邊框，增加精緻度 */
    display: flex;                                 /* 讓內部的按鈕左右並排 */
    
    /* 🚀 整合修正：增加換行許可，防止翻譯後擠壓 */
    flex-wrap: wrap;                               /* 空間不足時自動換行，避免重疊 */
    
    padding: 5px;                                  /* 讓內部的按鈕跟外框留一點點縫隙 */
    overflow: hidden;                              /* 確保內部按鈕的直角不會刺穿外框的圓角 */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);     /* 讓它有一點懸浮感 */
}

.tab-btn {
    flex: 1 1 50%;                                 /* 原始數據：預設各佔一半 */
    
    /* 🚀 整合修正：針對長單字語系進行防禦 */
    min-width: 120px;                              /* 確保按鈕有最低寬度 */
    height: auto;                                  /* 高度改為自動，配合文字換行 */
    white-space: normal;                           /* 核心修正：允許文字太長時自動換行，不橫向爆開 */
    line-height: 1.2;                              /* 調整行高，讓換行後的文字不顯擁擠 */
    
    padding: 15px 0;
    border: none;
    background: none;
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 10px;                          /* 原始數據：中文美觀的大字距 */
    cursor: pointer;
    color: #666;
    transition: color 0.3s;                        /* 🚀 修正：移除背景 transition 避免殘影 */
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}

.tab-btn.active {
    background-color: #2c7be5;                     /* 原始數據：改用填滿色 */
    color: white;                                  /* 原始數據：文字變白 */
    
    /* 🚀 修正殘影：調整圓角邏輯，使其完美貼合外框，不產生像素溢出 */
    border-radius: 45px;                           /* 稍微縮小半徑，使其在 padding 內完美貼合 */
    
    transition: none;                              /* 🚀 修正：Active 狀態不使用動畫，解決殘影問題 */
}

.tab-content {
    animation: fadeIn 0.4s ease-in-out;
}

/* =============================================================================
   🌍 語系補償規則 (當偵測到非中文語系時自動套用)
   ============================================================================= */

/* 當 Google 翻譯為英文、越南文、印尼文時，縮小字距以節省空間 */
html[lang="en"] .tab-btn, 
html[lang="vi"] .tab-btn, 
html[lang="id"] .tab-btn {
    letter-spacing: 1px !important;               /* 英文單字長，必須縮小字距防止溢出 */
    font-size: 16px !important;                    /* 稍微調降字體大小 */
    padding: 10px 5px !important;                  /* 調整內距讓文字有呼吸空間 */
}

/* 偵測非中文狀態時，微調容器圓角以適應可能的換行 */
html:not([lang="zh"]):not([lang="zh-TW"]) .tabs {
    border-radius: 25px !important;               /* 翻譯模式下縮小圓角，確保排版穩定 */
}

html:not([lang="zh"]):not([lang="zh-TW"]) .tab-btn.active {
    border-radius: 20px !important;               /* 同步調整選取態圓角 */
}

/* =============================================================================
   7. 下拉選單與輸入組件 (Selectors & Inputs)
   ============================================================================= */
/* --- 下拉選單外框容器 --- */
.selector { 
    margin: 20px; 
    padding: 15px; 
    background: rgba(255, 255, 255, 0.2); 
    backdrop-filter: blur(5px); 
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid #e0e0e0;
    border-radius: 50px; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.4); 
}

/* --- 選單欄位上方標語文字 --- */
.slogan-text {
    display: block;
    font-size: 14px;
    letter-spacing: 2px;
    color: #666;
    margin-bottom: 12px;
    font-weight: bold;
    text-align: center;
}

/* --- 統一欄位佈局容器 --- */
.selector-row {
    display: flex; 
    gap: 10px; 
    justify-content: center; 
    max-width: 500px; 
    margin: 0 auto;
}

/* --- 下拉選單與輸入框樣式 --- */
.selector-row select, 
.selector-row input {
    flex: 1 1 50%;
    width: 50%;
    min-width: 0;
    height: 38px;            
    font-size: 17px; 
    letter-spacing: 5px;        
    padding: 0 10px;         
    border: 2px solid #e0e0e0;
    color: #fff;
    font-weight: bold;
    border-radius: 20px;      
    background-color:  rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
    outline: none;
    transition: all 0.2s;
    text-align: center;
    -webkit-appearance: none; /* 移除 iOS 預設樣式 */
    appearance: none; /* 移除 Android 預設樣式 */
}

/* 自定義下拉箭頭圖示 */
.selector-row select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%23FFF' d='M1 4l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 35px;
}

select {
    text-align: center;
    text-align-last: center; /* 這是針對某些瀏覽器顯示選中項目的關鍵 */
    padding-left: 0;
    padding-right: 0;
}

/* =============================================================================
   8. 相機入口 UI (Camera Entry UI)
   ============================================================================= */
/* 外層容器：負責整體間距 */
.camera-entry-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
    margin-bottom: 5px;
}

/* 相機底框樣式 */
.camera-icon-bg {
    width: 60px;
    height: auto !important; 
    min-height: 140px;      
    background: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: visible !important; 
    padding: 25px 10px;     
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    -webkit-backface-visibility: hidden;
    transition: opacity 0.3s ease;
}

/* 啟動按鈕本體 */
#start-cam-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;      
    border: none;
    width: 20%;
    height: auto;
    cursor: pointer;
    outline: none;
    -webkit-tap-highlight-color: transparent; /* 🚀 核心修正：移除 iOS 點擊閃爍 */
    outline: none;
}

/* 圖示圓形外圈 */
#btn-icon-wrapper {
    background: #2c7be5 !important;   
    width: 60px;
    height: 60px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px; 
    box-shadow: 0 4px 10px rgba(0, 162, 255, 0.8);
    -webkit-appearance: none;
    transform: translateZ(0); 
}

/* Material Icons 圖示微調 */
#btn-icon-wrapper .material-icons {
    font-size: 32px !important;
    color: white !important;
}

/* =============================================================================
   9. 智能辨識實時介面 (Camera Live Interface)
   ============================================================================= */
/* 水平儀/輔助線容器 */
#level-container {
    position: absolute;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 200px;
    height: 100px;
    z-index: 999;
    pointer-events: none;
}

/* 掃描框引導視覺效果 */
#scan-guide-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 260px;
    height: 120px;
    background:
        linear-gradient(to right, #ffea00 6px, transparent 6px) 0 0,
        linear-gradient(to bottom, #ffea00 6px, transparent 6px) 0 0,
        linear-gradient(to left, #ffea00 6px, transparent 6px) 100% 0,
        linear-gradient(to bottom, #ffea00 6px, transparent 6px) 100% 0,
        linear-gradient(to right, #ffea00 6px, transparent 6px) 0 100%,
        linear-gradient(to top, #ffea00 6px, transparent 6px) 0 100%,
        linear-gradient(to left, #ffea00 6px, transparent 6px) 100% 100%,
        linear-gradient(to top, #ffea00 6px, transparent 6px) 100% 100%;
    background-repeat: no-repeat;
    background-size: 12px 12px;
    /* 入場動畫，跑一次就停止 */
    animation: focusEntrance 0.8s ease-out forwards; 
    opacity: 0; 
}

.scan-anim-active {
    animation: focusEntrance 0.8s ease-out forwards,
               scanBreath 5s infinite ease-in-out 0.8s !important;
    opacity: 1;
}

/* 掃描中心十字準星線 */
.cross-line {
    position: absolute;
    background: rgba(255, 234, 0, 0.6);
    top: 50% !important;
    left: 50% !important;
}

.line-h {
    width: 180px;
    height: 3px;
    transform: translate(-50%, -50%);
}

.line-v {
    width: 2px;
    height: 60px;
    transform: translate(-50%, -50%);
}

/* =============================================================================
   10. 相機疊層文字提示 (Camera Overlay Text)
   ============================================================================= */
/* --- 相機畫面內的提示文字 --- */
#instruction-text {
    position: absolute;    
    top: 15px;             
    left: 50%;             
    transform: translateX(-50%); 
    width: 90%;            
    max-width: 400px;      
    padding: 0;        
    color: #FFD700;        
    font-weight: bold;     
    font-size: 16px;       
    letter-spacing: 2px;   
    text-align: center;    
    z-index: 2000;         
    background: none; 
    border-radius: 8px;    
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8); 
    pointer-events: none;  
    white-space: normal;   
    line-height: 1.4;      
}

/* --- 相機下緣的狀態文字 (正在啟動 / 辨識中) --- */
#status-text {
    position: absolute;    
    bottom: 15px;          
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    z-index: 1010;         
    color: #FFD700;        
    font-size: 16px;
    letter-spacing: 2px;
    font-weight: bold;
    text-align: center;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.9);
    pointer-events: none;
}

/* =============================================================================
   11. 智能客服與 FAQ 樣式 (Chatbot & FAQ)
   ============================================================================= */
/* FAQ 單個項目外框 */
.faq-item {
    background: white;
    margin: 10px 0;
    padding: 15px;
    border-radius: 10px;
    text-align: left;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

#consult-faq {
    box-sizing: border-box !important;    /* 🚀 強制撐開：確保在手機上內容能流動 */
    width: 100% !important;
    max-width: 800px !important;
    margin: 0 auto !important;
    display:none; 
    text-align:left; 
    padding: 10px 20px;
}

/* 智能客服懸浮容器 */
.apo-bot {
    position: fixed !important;
    bottom: 20px;
    right: 20px;
    z-index: 99999 !important;
    display: flex;
    align-items: center;
}

/* 客服對話氣泡樣式 */
.apo-talk-bubble {
    background: white;
    padding: 8px 15px;
    border-radius: 30px;
    font-size: 13px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    margin-right: 10px;
    border: 1px solid #eee;
    opacity: 0;
    visibility: hidden;
    transition: 0.4s;
    pointer-events: none;
}

/* 當處於辨識中或輸入中時，強制氣泡消失且不佔空間 */
.apo-talk-bubble.force-hide {
    opacity: 0 !important;
    visibility: hidden !important;
    transform: translateX(10px) scale(0.8) !important; /* 縮小並往右側藏 */
    pointer-events: none !important; /* 確保點擊穿透 */
    transition: all 0.3s ease;
}

/* 客服圓形圖示容器 */
.apo-icon-container {
    width: 60px;
    height: 60px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 2px solid #00847b;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

/* 懸停時顯示對話氣泡 */
.apo-bot:hover .apo-talk-bubble {
    opacity: 1;
    visibility: visible;
    transform: translateY(-5px);
}

.apo-icon-container img {
    width: 85%;
    height: auto;
}

/* =============================================================================
   12. 視覺美化：漸層與動畫 (Visuals & Animations)
   ============================================================================= */
/* --- 漸層標題組 --- */
.smart-gradient-title {
    background: linear-gradient(to right, #4b2c82 0%, #6a5acd 45%, #2d3e91 100%) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    color: transparent !important;
    font-weight: 800 !important;
    letter-spacing: 1px !important;
    font-size: 22px !important;
    display: inline-block !important;
    font-family: "PingFang TC", "Heiti TC", "Microsoft JhengHei", sans-serif;
    filter: drop-shadow(0px 1px 1px rgba(0, 0, 0, 0.1));
    margin: 0;
    padding: 2px 0;
}

.classic-4color-gradient {
    background: linear-gradient(to right,#0000FF 25%, #87CEFA 38%, #00FFFF 48%, #FFD700 53%, #FFB347 58%, #FFB6C1 68%, #FF0000 78%) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    color: transparent !important;
    font-weight: 900 !important;
    display: block !important;
    text-align: center;
    width: 100%;
    letter-spacing: 1px;
}

/* --- 動畫 Keyframes --- */
@keyframes scanBreath {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    50% { transform: translate(-50%, -50%) scale(1.05); opacity: 0.7; }
}

@keyframes focusEntrance {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(1.2); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

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

@keyframes mobilePulseReminder {
    0%, 5% { opacity: 0; visibility: hidden; }
    10%, 25% { opacity: 1; visibility: visible; }
    30%, 100% { opacity: 0; visibility: hidden; }
}

/* =============================================================================
   13. 行動裝置適配與修正 (RWD Fixes)
   ============================================================================= */
/* 針對 Android 字體鎖定修正 */
#formatted-result, .faq-answer {
    -webkit-text-size-adjust: none !important;
    text-size-adjust: none !important;
    line-height: 1.5 !important;
    max-height: 999999px;
}

/* --- 橫向模式鎖定 --- */
/* 🚀 移除原本的媒體查詢，改用全域鎖定 */
html, body {
    -webkit-text-size-adjust: 100% !important;
    text-size-adjust: 100% !important;
}

/* 針對橫向模式的 FAQ 特殊補強 */
@media screen and (orientation: landscape) {
    /* 確保所有文字容器都遵循 100% */
    * {
        -webkit-text-size-adjust: 100% !important;
        text-size-adjust: 100% !important;
    }

    /* 針對你提到的 FAQ 答案區與結果區 */
    #formatted-result p, 
    #formatted-result div, 
    .faq-answer,
    .faq-item * { 
        line-height: 1.6 !important;
        /* 🚀 移除 max-height: 999999px，改用下面這行穩定版面 */
        overflow-wrap: break-word; 
    }
}

/* --- 手機版選單排版微調 --- */
@media screen and (max-width: 480px) {
    .selector-row { gap: 8px; }
    .selector-row select, .selector-row input { height: 36px; font-size: 14px; padding: 0 8px; }
    .selector-row select { background-position: right 8px center; padding-right: 22px; }
    .slogan-text { font-size: 13px; }
}

/* --- 手機版智能客服位置修正 --- */
@media screen and (max-width: 768px) {
    .apo-bot { bottom: 45px !important; }
    .apo-talk-bubble { animation: mobilePulseReminder 30s infinite !important; }
}

/* 針對手機窄螢幕的微調(FAQ分頁) */
@media (max-width: 480px) {
    #consult-faq h3 {font-size: 1.1rem !important; }   /* 標題小一點，避免折行太嚴重 */
    .faq-q-title { font-size: 15px !important; }       /* 調整 Q 和 A 的字體，適合閱讀 */
    .faq-main-answer { font-size: 15px !important; }
}

/* =============================================================================
   14. 影片組件與預覽 (Video Preview)
   ============================================================================= */
/* 影片預覽圖外殼，負責圓角和邊框 */
.video-container {
    width: 92%;
    max-width: 400px;
    margin: 20px auto;
    border-radius: 20px;            /* 圓角設定 */
    overflow: hidden;               /* 核心：裁切掉影片的尖角 */
    background-color: transparent;  /* 背景設為透明 */
    border: 1px solid #e0e0e0; 
    box-shadow: 0 4px 10px rgba(44, 123, 229, 0.8);
}

/* 裡面的影片 */
.video-container video {
    display: block;
    width: 100%;
    object-fit: cover; /* 防止影片兩側出現黑邊 */
    background-color: transparent;/* 影片背景透明 */
}

/* =============================================================================
   🔍 搜尋浮層專用樣式 (完整隔離版：確保不影響首頁開啟相機按鈕)
   ============================================================================= */

/* 1. 最外層半透明背景遮罩 */
#full-screen-search.vsh-search-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* 2. 搜尋主方框 (對齊 .selector 質感：20% 透明白 + 磨砂) */
#full-screen-search .vsh-search-modal {
    position: absolute;
    top: 5%;
    left: 5%;
    width: 90%;
    background: rgba(255, 255, 255, 0.2); 
    backdrop-filter: blur(5px); 
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid #e0e0e0;
    border-radius: 40px;
    padding: 15px; 
    box-sizing: border-box;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
    max-height: 85%;
    overflow: hidden;
    display: flex; 
    flex-direction: column;
}

/* 🚀 搜尋頭部容器：確保返回鍵與輸入框並排且不溢出 */
#full-screen-search .vsh-search-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 5px;
    width: 100%;
    box-sizing: border-box;
}

/* 3. 搜尋輸入框本體 (白色高對比背景) */
#full-screen-search .vsh-search-input-field {
    flex: 1;
    min-width: 0;
    height: 48px;
    border-radius: 25px;
    border: 2px solid white;
    padding: 0 18px;
    font-size: 17px;
    outline: none;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.8);
    color: #333;
    font-weight: bold;
    letter-spacing: 1px;
}

/* 4. 輸入框 Placeholder */
#full-screen-search .vsh-search-input-field::placeholder {
    color: #666;
    font-weight: bold;
    letter-spacing: 1px;
}

/* 5. 返回按鈕 (精確隔離：防止推擠首頁佈局) */
#full-screen-search .vsh-search-back-btn {
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    white-space: nowrap; /* 確保「返回」不換行 */
    padding: 5px 0 5px 10px;
    display: inline-block;
    flex-shrink: 0; /* 禁止縮小，確保點擊範圍 */
    letter-spacing: 2px;
}

/* 6. 中間提示標題 (💡 您可以嘗試搜尋...) */
#full-screen-search .vsh-search-hint-text {
    text-align: center;
    color: white;
    padding: 10px 0;
    font-size: 18px;
    font-weight: bold;
    letter-spacing: 2px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* 9. 搜尋引導清單區塊 (調整間距緊湊化) */
#full-screen-search .vsh-search-hint-box {
    padding: 0 10px;
    margin-top: -5px;
}

#full-screen-search .vsh-search-hint-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

#full-screen-search .vsh-search-hint-list li {
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.2); 
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 12px 15px;
    border-radius: 15px;
    color: white;
    font-size: 15px;
}

/* 7. 搜尋結果滾動區 */
#full-screen-search .vsh-search-results-container {
    flex: 1;
    overflow-y: auto;
    text-align: left;
}

/* 8. 搜尋結果單筆項目 */
#full-screen-search .search-result-item {
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

#full-screen-search .search-result-title {
    font-weight: bold;
    color: white;
    font-size: 16px;
    letter-spacing: 1px;
}

#full-screen-search .search-result-category {
    color: rgba(255, 255, 255, 0.7);
    font-weight: bold;
    font-size: 12px;
}

#full-screen-search .search-result-arrow {
    color: rgba(255, 255, 255, 0.5);
}

#consultSearch::placeholder {
    color: #fff;         
}

/* 統計項目預設先隱藏，交由 JS 根據配置決定是否顯示 */
#display-total-views-wrapper, 
#display-total-consults-wrapper, 
#display-total-plays-wrapper, 
#display-total-ocr-wrapper,
#examCountText,
#display-consult-count-wrapper {
    display: none;
}
