/* ============================================================
   🤖 祥興茶行 AI 導購與隱藏菜單樣式表 (完整版)
   ============================================================ */

/* === Modal Overlay (遮罩) === */
.ai-modal-overlay {
  position: fixed; inset: 0; display: flex; justify-content: center; align-items: flex-end;
  padding: 0 0 40px; background: rgba(0,0,0,0.25);
  -webkit-backdrop-filter: var(--hh-scrim-blur);
  backdrop-filter: var(--hh-scrim-blur);
  opacity: 0; pointer-events: none; transition: opacity .28s ease; 
  z-index: var(--z-ai-backdrop, 9997) !important; /* 壓制 ai-shop.js:1602 對 loadingBubble 寫的 inline z-index 9999 */
  padding-bottom: env(safe-area-inset-bottom);
}
.ai-modal-overlay.show { opacity: 1; pointer-events: auto; }
/* === 2. 手機版底部間距優化 === */
@media (max-width: 600px) {
  .ai-box {
    /* 確保輸入框不會貼底貼太緊 */
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
}
/* === AI Modal Card (主視窗) === */
.ai-box {
  width: 92%; max-width: 450px; max-height: 80vh;
  display: flex; flex-direction: column; padding: 20px 20px 16px; border-radius: 22px;
  background: rgba(255,255,255,0.60);
  backdrop-filter: blur(22px) saturate(180%); -webkit-backdrop-filter: blur(22px) saturate(180%);
  box-shadow: 0 20px 42px rgba(50,70,60,0.22), 0 6px 14px rgba(50,70,60,0.15), inset 0 0 0 1px rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.65);
  animation: aiPopIn .36s cubic-bezier(.18,.9,.32,1.2);
  overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y;
  z-index: var(--z-ai-chat, 9998);
}
@keyframes aiPopIn {
  0% { transform: translateY(20px) scale(.92); opacity: 0; filter: blur(3px); }
  55% { transform: translateY(-4px) scale(1.02); opacity: 1; filter: blur(0); }
  100% { transform: translateY(0) scale(1); }
}

/* === AI Title === */
.ai-title {
  font-size: 1.2rem; font-weight: 800; color: #2f4b3c; text-align: center; margin-bottom: 15px;
  display: flex; align-items: center; justify-content: center; gap: 8px; flex-shrink: 0;
}

/* === Close Button === */
.ai-close-icon {
  position: absolute; top: 12px; right: 14px; width: 38px; height: 38px;
  display: flex; justify-content: center; align-items: center;
  font-size: 18px; font-weight: 700; color: #3a5c48;
  background: rgba(255,255,255,0.48); border: 1px solid rgba(200,220,210,0.55); border-radius: 50%;
  box-shadow: 0 8px 20px rgba(70,100,80,0.20), inset 0 0 0 1px rgba(255,255,255,0.55);
  backdrop-filter: blur(12px); cursor: pointer; transition: .25s ease;
}
.ai-close-icon:hover { transform: scale(1.08); box-shadow: 0 14px 34px rgba(70,100,80,0.28); }

/* === AI 入口按鈕 === */
.ai-assist-btn {
  width: 100%; padding: 16px 24px; margin-bottom: 22px;
  font-size: 17px; font-weight: 760; color: #2f4b3c; letter-spacing: 0.4px;
  background: rgba(255, 255, 240, 0.55); border: 1px solid rgba(190, 205, 180, 0.60); border-radius: 18px;
  box-shadow: 0 14px 28px rgba(120,150,110,0.20), inset 0 0 0 1px rgba(255,255,255,0.45);
  backdrop-filter: blur(18px); display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all .28s ease; cursor: pointer;
}
.ai-assist-btn:hover {
  background: rgba(255, 255, 250, 0.70); border-color: #bcd8a2; transform: translateY(-3px);
}

/* === Chat Area === */
.ai-chat-area {
  display: flex; flex-direction: column; gap: 14px; margin-top: 14px;
  max-height: 70vh;
  max-height: 70dvh; /* iOS 動態視口（舊 Safari 吃上行 fallback） */
  overflow-y: auto; scroll-behavior: smooth;
  padding-right: 4px; touch-action: pan-y; -webkit-overflow-scrolling: touch; flex-grow: 1;
}

/* === Bubbles === */
.ai-bubble {
  max-width: 90%; margin: 10px 0; padding: 16px 18px; border-radius: 18px;
  line-height: 1.65; font-size: 0.95rem; color: #2f4b3c;
  background: rgba(245, 255, 245, 0.55); border: 1px solid rgba(165, 190, 165, 0.50);
  box-shadow: 0 8px 30px rgba(120,150,120,0.20); backdrop-filter: blur(18px);
  animation: aiBubbleFade .25s ease; word-break: break-word;
}
.ai-bubble-ai { align-self: flex-start; border-top-left-radius: 6px; background: rgba(250,255,245,0.60); }
.ai-bubble-user {
  /* 2026-07-03 健檢修：原淺鼠尾草綠底×白字對比僅 ~1.9:1，改深茶綠底保白字可讀 */
  align-self: flex-end; background: linear-gradient(135deg, #3e5c48, #5a7b68);
  color: #ffffff; border: none; box-shadow: 0 6px 22px rgba(62,92,72,0.28);
}
.ai-bubble-title {
  /* 2026-07-03 健檢修：漸層透明字（反參考明列）改實色深墨綠 */
  font-size: 17px; font-weight: 800; margin-bottom: 8px;
  color: #2c5c45;
}
/* 2. 重點文字 (Bold) - 用顯眼的深橘色或茶褐色 */
.ai-bubble strong {
  color: #9a7327; /* 2026-07-03 健檢修：南瓜橘偏促銷感→琥珀茶湯色 */ 
  font-weight: 700;
  background-color: rgba(255, 243, 224, 0.5); /* 淡淡的底色強調 */
  padding: 0 2px;
  border-radius: 2px;
}

/* 3. 條列式清單 (List) - 縮排與樣式 */
.ai-bubble ul, .ai-bubble ol {
  margin: 8px 0;
  padding-left: 24px; /* 讓圓點縮進去一點 */
}

.ai-bubble li {
  margin-bottom: 4px; /* 列表項目之間留點呼吸空間 */
}

/* 4. 段落 (Paragraph) - 段落間距 */
.ai-bubble p {
  margin-bottom: 10px; 
}
.ai-bubble p:last-child {
  margin-bottom: 0; /* 最後一段不要留白 */
}

/* 5. 標題 (Heading) - 雖然阿興師很少用標題，但預防萬一 */
.ai-bubble h3, .ai-bubble h4 {
  margin: 12px 0 6px 0;
  font-size: 1.1em;
  color: #2c5c45; /* 茶綠色 */
  font-weight: bold;
  border-bottom: 1px dashed #ccc; /* 下底線裝飾 */
  padding-bottom: 4px;
}
@keyframes aiBubbleFade { from { opacity: 0; transform: translateY(6px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* === Input Area === */
.ai-input-row {
  display: flex;
  align-items: center;
  gap: 10px; /* 拉開間距 */
  margin-top: 16px;
  padding: 12px 16px;
  
  background: #ffffff;
  border: 1px solid rgba(180, 200, 185, 0.3);
  border-radius: 24px; /* 更大的圓角 */
  
  /* 懸浮陰影 */
  box-shadow: 0 4px 20px rgba(0,0,0,0.04);
  backdrop-filter: blur(14px);
  
  /* 固定在底部時的優化 */
  flex-shrink: 0;
}
.ai-text-input {
  flex: 1;
  height: 44px; /* 加高 */
  padding: 0 12px;
  font-size: 16px;
  
  border: none; /* 移除邊框，因為外層已經有框了 */
  background: transparent;
  color: #2f4b3c;
  font-weight: 500;
  
  transition: all .28s ease;
}
.ai-text-input:focus {
  outline: none;
}
.ai-text-input::placeholder {
  color: #aabcb2;
  font-weight: 400;
}

/* === Camera & Send Buttons === */
.ai-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #f0f5f3; /* 淡綠底 */
  color: #5a7b68;
  font-size: 20px;
  display: flex; 
  align-items: center; 
  justify-content: center;
  transition: all 0.2s;
  padding: 0; /* 重置 */
}

.ai-icon-btn:hover {
  background: #e0ebe6;
  color: #2f4b3c;
  transform: scale(1.1);
}

.ai-send-btn {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  padding: 0; /* 強制移除多餘內距 */
  
  background: linear-gradient(135deg, #5a7b68, #7fa38a);
  border: none;
  box-shadow: 0 4px 10px rgba(90, 123, 104, 0.3), inset 0 1px 0 rgba(255,255,255,0.3);
  
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  flex-shrink: 0;
}

.ai-send-btn:hover {
  transform: translateY(-2px) scale(1.05);
  background: linear-gradient(135deg, #668a75, #8fb79c);
  box-shadow: 0 6px 16px rgba(90, 123, 104, 0.4);
}

.ai-send-btn:active {
  transform: scale(0.95);
  box-shadow: 0 2px 6px rgba(90, 123, 104, 0.2);
}

/* 🔥 這裡修正你的 icon 樣式 */
.ai-send-btn i {
  font-size: 20px;
  color: #ffffff;
  /* 視需要微調位置，如果覺得歪歪的 */
  margin-left: 2px; 
  margin-top: 1px;
}

/* === Loading Animation === */
.dot-flashing { position: relative; width: 8px; height: 8px; border-radius: 5px; background-color: #999; color: #999; animation: dot-flashing 1s infinite linear alternate; animation-delay: 0.5s; margin: 0 12px; }
.dot-flashing::before, .dot-flashing::after { content: ""; display: inline-block; position: absolute; top: 0; width: 8px; height: 8px; border-radius: 5px; background-color: #999; color: #999; animation: dot-flashing 1s infinite alternate; }
.dot-flashing::before { left: -12px; animation-delay: 0s; }
.dot-flashing::after { left: 12px; animation-delay: 1s; }
@keyframes dot-flashing { 0% { background-color: #999; } 50%, 100% { background-color: #e0e0e0; } }

/* === 🕵️ Secret Card (隱藏版商品) === */
.secret-card {
  background: linear-gradient(135deg, #fff9f0 0%, #fff 100%);
  border: 1px solid #d4af37; box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
  position: relative; overflow: hidden;
}
.secret-card::before {
  content: ""; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
  background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.8) 50%, rgba(255, 255, 255, 0) 100%);
  transform: rotate(45deg); animation: shine 3s infinite; pointer-events: none;
}
@keyframes shine { 0% { transform: translateX(-150%) rotate(45deg); } 100% { transform: translateX(150%) rotate(45deg); } }
.secret-card .prod-name { color: #b8860b; font-weight: bold; }

/* === AI Options & Products === */
.ai-option-group { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.ai-option-btn {
  padding: 8px 14px; font-size: 14px; border-radius: 12px;
  background: rgba(255,255,245,0.65); border: 1px solid rgba(180,200,170,0.50);
  color: #2f4b3c; box-shadow: 0 5px 14px rgba(130,160,130,0.18); cursor: pointer; transition: .25s ease;
}
.ai-option-btn:hover { background: rgba(255,255,255,0.82); border-color: #bcd99f; transform: translateY(-2px); }

.ai-prod-item {
  margin-top: 12px; padding: 12px 14px; background: rgba(255,255,250,0.65);
  border: 1px solid rgba(170,190,170,0.50); border-radius: 14px; cursor: pointer;
  box-shadow: 0 6px 18px rgba(120,150,110,0.20); transition: all .25s ease;
}
.ai-prod-item:hover { background: rgba(255,255,255,0.85); transform: translateY(-2px); border-color: #9ac89f; }

/* === 📦 Blocks (Brew, Compare, etc.) === */
.brew-item { padding: 10px 12px; background: rgba(255,255,245,0.55); border: 1px solid rgba(185,200,180,0.50); border-radius: 12px; margin-bottom: 10px; }
.brew-tips { margin-top: 10px; padding: 10px 12px; background: rgba(250,255,245,0.65); border: 1px dashed rgba(160,185,160,0.6); border-radius: 12px; font-size: 14px; color: #3c5c46; }

.compare-block { margin-top: 12px; padding: 16px; background: rgba(255,255,245,0.65); border: 1px solid rgba(190,205,180,0.50); border-radius: 16px; display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 10px; }
.compare-summary { margin-top: 12px; padding: 12px 14px; background: rgba(255,255,245,0.75); border-radius: 14px; border: 1px solid rgba(200,210,185,0.50); font-size: 14.5px; line-height: 1.7; color: #304c3a; }

/* 🔥【補全】其他 AI 區塊樣式 */
.pairing-summary { font-size: 14.5px; color: #3c5c46; margin-bottom: 10px; line-height: 1.7; }
.gift-summary { font-size: 15px; color: #35543d; margin-bottom: 10px; line-height: 1.7; }

.person-summary { font-size: 15px; color: #355c45; opacity: .92; line-height: 1.7; margin-bottom: 12px; }

/* 🔥【補全】隱藏版 Modal 專用按鈕 (Gold Theme) */
.secret-qty-btn {
  width: 30px; 
  height: 30px; 
  border: 1px solid #ddd; 
  background: #fff; 
  border-radius: 50%;
  cursor: pointer; 
  font-size: 1.2rem; 
  line-height: 1; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  color: #b8860b;
}
.secret-qty-btn:hover { 
  background: #fffbf0; 
  border-color: #b8860b; 
}

/* 💌 茶籤按鈕 */
.ai-card-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 10px 0;
  background: linear-gradient(135deg, #fffaf0, #fff5e0);
  border: 1px solid #e0d0b0;
  border-radius: 12px;
  color: #b8860b; /* 金色文字 */
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  box-shadow: 0 2px 6px rgba(184, 134, 11, 0.1);
  transition: all 0.3s ease;
}
/* 載入中 */
.loading-state {
  pointer-events: none; /* 禁止連點 */
  opacity: 0.7;
}

/* 準備就緒 */
.ready-state {
  background: linear-gradient(45deg, #2f4b3c, #4a7c64);
  color: #fff !important; /* 暫態競爭：ai-shop.js loading 期間對按鈕寫 inline color */
  box-shadow: 0 4px 12px rgba(47, 75, 60, 0.3);
  animation: popIn 0.3s ease-out;
}

@keyframes popIn {
  0% { transform: scale(0.95); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.ai-card-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(184, 134, 11, 0.2);
  background: #fffbf5;
}

.ai-audio-btn {
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(160,180,165,0.5);
  border-radius: 10px;
  font-size: 14px;
  color: #324b3f;
  cursor: pointer;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 12px rgba(90,123,104,0.15);
  transition: 0.25s ease;
}

.ai-audio-btn:hover {
  background: rgba(255,255,255,0.75);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(90,123,104,0.25);
}
/* ============================================================
   📱 手機版優化：轉變為 Bottom Sheet 模式
   (貼在 ai-chat.css 最下方)
   ============================================================ */

@media (max-width: 600px) {
  /* 1. 調整遮罩層：讓內容貼底 */
  .ai-modal-overlay {
    padding-bottom: 0; /* 移除底部留白 */
    align-items: flex-end; /* 確保靠下對齊 */
  }

  /* 2. 主視窗變形：更寬、更高、更靈活 */
  .ai-box {
    width: 100%;      /* 寬度佔滿 */
    max-width: 100%;  /* 解除最大寬度限制 */
    
    /* 高度控制：關鍵 */
    height: auto;      /* 讓高度隨內容自動長高 */
    min-height: 50vh;  /* 初始高度至少佔一半螢幕 (看起來才大氣) */
    max-height: 92dvh; /* 最高長到螢幕的 92% (預留一點頂部空間) */
    
    /* 造型調整：變成抽屜 */
    border-radius: 28px 28px 0 0; /* 只有上面有圓角 */
    border-bottom: none;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.15);
    
    padding: 20px 16px 30px; /* 調整內距，底部留多一點給手勢 */
  }

  /* 3. 對話區域：確保能撐開父容器 */
  .ai-chat-area {
    /* 讓它佔據空間，但不要強迫出現捲軸，除非父容器已達 max-height */
    flex: 1; 
    min-height: 0; /* Flexbox 溢出修復 */
    
    /* 修正內距，避免文字貼邊 */
    padding-left: 4px;
    padding-right: 4px;
  }

  /* 4. 輸入框區域：固定在底部 */
  .ai-input-row {
    margin-top: 16px;
    background: #f7f9f8; /* 稍微深一點的底色，區分輸入區 */
  }
  
  /* 5. 修正關閉按鈕位置 */
  .ai-close-icon {
    top: 16px;
    right: 16px;
    background: rgba(240, 240, 240, 0.8); /* 讓它在手機上更明顯 */
  }
}

/* === 📸 修正使用者上傳圖片樣式 === */
.ai-bubble-img {
  display: block;
  max-width: 100%;       /* 確保不超過氣泡範圍 */
  height: auto;          /* 保持比例 */
  max-height: 300px;     /* 限制最大高度，避免洗版 */
  border-radius: 12px;   /* 圖片圓角 */
  margin-top: 4px;
  object-fit: cover;     /* 裁切填滿 */
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* === 🖼 美化茶籤 Modal 的關閉按鈕 === */
#closeTeaCardModal {
  /* 覆蓋原本 ai-send-btn 的圓形設定 */
  width: 100% !important; /* 以下至 color 共 5 個 !important 必要：對抗模板 inline style（ai-shop.js:1823） */
  height: auto !important;
  border-radius: 12px !important; /* 改回正常的圓角 */
  padding: 12px 0 !important;     /* 增加上下高度 */
  margin-top: 16px;
  
  /* 按鈕配色 (深綠色系，搭配茶行風格) */
  background: linear-gradient(135deg, #2f4b3c, #1a2e24);
  color: #fff !important;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1px;
  border: none;
  box-shadow: 0 4px 12px rgba(47, 75, 60, 0.3);
  
  /* 移除原本 icon 的偏倚 */
  display: flex;
  align-items: center;
  justify-content: center;
}

#closeTeaCardModal:hover {
  background: linear-gradient(135deg, #3e5c4a, #2a4034);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(47, 75, 60, 0.4);
}

#closeTeaCardModal:active {
  transform: scale(0.98);
}
/* ============================================================
   🍌 茶籤 Modal 專用樣式（避免遮擋重要位置）
   ============================================================ */
.tea-card-modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end; /* 🔥 關鍵：從底部對齊 */
  padding: 0;
  background: rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: var(--hh-scrim-blur);
  backdrop-filter: var(--hh-scrim-blur);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: var(--z-ai-window, 10002); /* 預設比 Product Modal 高，可動態調整 */
}

.tea-card-modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.tea-card-modal-box {
  transform: translateY(100%); /* 初始位置在底部外 */
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  will-change: transform;
}

.tea-card-modal-overlay.show .tea-card-modal-box {
  transform: translateY(0); /* 滑入顯示 */
}

/* 🔥 當有 Product Modal 或 StickyBar 時，調整 z-index */
.tea-modal.show ~ .tea-card-modal-overlay,
#StickyBar.sticky-high-z ~ .tea-card-modal-overlay {
  z-index: var(--z-ai-modal, 10000) !important; /* 在 Product Modal 下方 */
}

/* 手機版優化 */
@media (max-width: 600px) {
  .tea-card-modal-box {
    width: 100% !important; /* 以下 4 個 !important 必要：對抗 .tea-card-modal-box 模板 inline style（ai-shop.js:1798） */
    max-width: 100% !important;
    border-radius: 24px 24px 0 0 !important;
    max-height: 80vh !important;
    max-height: 80dvh !important; /* iOS 動態視口（舊 Safari 吃上行 fallback） */
  }
}

/* ============================================================
   🏷️ 獨立卡片模式 (Card Mode - 終極防切版)
   請直接覆蓋原本的 Card Mode 區塊
   ============================================================ */

.ai-card-container {
  /* 1. 排版結構：改用 Flex Column，這是解決高度計算錯誤的關鍵 */
  display: flex;
  flex-direction: column;
  
  /* 2. 尺寸設定 */
  width: 100%;
  min-width: 300px; /* 防止在極窄螢幕變形 */
  max-width: 100%;
  height: auto; /* 🔥 強制高度隨內容自動長高 */
  
  /* 3. 外觀設定 */
  background: #fff;
  border-radius: 12px;
  /* 陰影稍微加深，增加立體感 */
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  margin: 12px 0;
  border: 1px solid #eee;
  
  /* 4. 關鍵修正：移除 overflow: hidden */
  /* 這樣就算內容超出 1px，也不會被無情切斷，而是會撐開容器 */
  overflow: visible; 
}

/* --- 標題區 --- */
.ai-card-header {
  /* 手動設定圓角 (只圓上面兩個角) */
  border-radius: 12px 12px 0 0;
  
  background: #5c7c5c;
  color: #fff;
  padding: 12px 16px;
  font-weight: bold;
  font-size: 15px;
  letter-spacing: 1px;
  
  /* 防止標題被壓縮 */
  flex-shrink: 0;
}

/* --- 表格區 (Body) --- */
.ai-card-body {
  /* 允許左右滑動，但禁止上下滑動(由父層處理) */
  overflow-x: auto;
  overflow-y: hidden;
  
  /* 讓表格區塊佔據中間剩餘空間 */
  flex: 1 1 auto;
}

.tea-compare-table {
  width: 100%;
  border-collapse: collapse;
  /* 固定表格算法，避免內容把格子撐壞 */
  table-layout: fixed; 
}

.tea-compare-table th {
  background-color: #f8f9fa;
  padding: 12px 8px;
  vertical-align: middle;
  border-bottom: 2px solid #e9ecef;
  text-align: center;
  transition: all 0.2s ease;
}

.tea-compare-table th[data-prod]:hover {
  background-color: #edf2ee;
  color: #2f4b3c;
}

/* 表頭大字體 (取代圖片的標題) */
.th-text-large {
  color: #2c3e50;
  font-weight: bold;
  font-size: 14px;
  line-height: 1.3;
  
  /* 修正：統一排版邏輯 */
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  
  /* 增加高度與內距，避免文字貼頂或被切斷 */
  min-height: 48px; 
  padding: 6px 4px;
  
  /* 允許換行，但不強制限制行數 */
  word-break: break-word;
  overflow: visible;
}

/* 內容格 */
.tea-compare-table td {
  padding: 14px 10px;
  font-size: 13.5px;
  color: #444;
  text-align: center;
  border-bottom: 1px solid #f2f2f2;
  vertical-align: middle;
  word-wrap: break-word;
  line-height: 1.5;
}

/* 第一欄 (維度名) */
.tea-compare-table td.dim-col {
  font-weight: bold;
  color: #5c7c5c;
  background-color: #fafafa;
  font-size: 12px;
  width: 20%; /* 固定寬度 */
}

/* --- 底部點評 (Footer) --- */
.ai-card-footer {
  /* 手動設定圓角 (只圓下面兩個角) */
  border-radius: 0 0 12px 12px;
  
  background: #fffbf0;
  padding: 16px; /* 增加 padding 讓文字不貼邊 */
  border-top: 1px dashed #e0d0b0;
  
  /* 🔥 救命關鍵：設定為 0 代表「絕對不准壓縮我」 */
  /* 這能保證就算上面表格再長，底部這塊永遠完整顯示 */
  flex-shrink: 0; 
}

.expert-label {
  color: #9c8248;
  font-weight: bold;
  font-size: 13px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.expert-content {
  color: #5d5d5d;
  font-size: 13px;
  line-height: 1.6; /* 行高加大，提升閱讀舒適度 */
  text-align: justify;
}

/* === 🎁 雙罐禮盒推薦 === */
.ai-giftbox-bubble {
  background: linear-gradient(180deg, rgba(255,250,240,0.85), rgba(245,238,220,0.6));
  border: 1px solid rgba(193,154,107,0.45);
  padding: 16px;
}
.ai-giftbox-warning {
  background: rgba(255,200,150,0.5); border-left: 3px solid #d96a2c;
  padding: 8px 12px; font-size: 12px; color: #6b3010;
  border-radius: 6px; margin: 8px 0;
}
.ai-giftbox-note {
  background: rgba(180,220,255,0.4); border-left: 3px solid #5b8fbf;
  padding: 8px 12px; font-size: 12px; color: #2a4d6b;
  border-radius: 6px; margin: 8px 0;
}
.ai-giftbox-slots { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.ai-giftbox-slot {
  background: rgba(255,255,255,0.65); border: 1px solid rgba(193,154,107,0.35);
  border-radius: 10px; padding: 12px; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.ai-giftbox-slot:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(120,80,30,0.15); }
.ai-giftbox-slot-head { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: #2f4b3c; }
.ai-giftbox-slot-name { flex: 1; }
.ai-giftbox-slot-price { color: #8b5a2b; font-weight: 700; }
.ai-giftbox-role {
  display: inline-block; padding: 2px 8px; border-radius: 8px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.3px;
}
.ai-giftbox-role.main { background: #c19a6b; color: #fff; }
.ai-giftbox-role.alt  { background: rgba(193,154,107,0.25); color: #6b4423; }
.ai-giftbox-slot-tagline { font-size: 11px; color: #888; margin-top: 4px; }
.ai-giftbox-slot-reason { font-size: 13px; color: #5a5a5a; line-height: 1.5; margin-top: 6px; }
.ai-giftbox-summary {
  background: rgba(255,255,255,0.5); border-radius: 8px;
  padding: 10px 14px; margin: 12px 0 14px; font-size: 13px;
}
.ai-giftbox-line { display: flex; justify-content: space-between; padding: 3px 0; color: #555; }
.ai-giftbox-line.total {
  font-size: 16px; font-weight: 800; color: #2f4b3c;
  border-top: 1px dashed rgba(193,154,107,0.45); margin-top: 6px; padding-top: 8px;
}
/* 🎁 檔期禮盒折扣（2026-08-13）。折後價由後端算好帶下來；購物車仍存原價。 */
.ai-giftbox-line-promo { color: #8a5a1e; font-weight: 700; }
.ai-giftbox-was { color: #9aa89a; font-weight: 400; margin-right: 4px; }
.ai-giftbox-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.ai-giftbox-add-btn {
  flex: 1; min-width: 120px; padding: 12px;
  background: linear-gradient(135deg, #c19a6b, #a87a4e); color: #fff;
  border: none; border-radius: 999px;
  font-size: 14px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 14px rgba(168,122,78,0.35);
  transition: transform .15s ease;
}
.ai-giftbox-add-btn:hover { transform: translateY(-2px); }
.ai-giftbox-add-btn:disabled { opacity: 0.7; transform: none; cursor: default; }
.ai-giftbox-tune-btn {
  flex: 1; min-width: 120px; padding: 12px;
  background: rgba(255,255,255,0.75); color: #6b4423;
  border: 1px solid rgba(193,154,107,0.55); border-radius: 999px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.ai-giftbox-tune-btn:hover { background: rgba(255,255,255,0.95); }

/* === 🧑‍🍳 真人接手相關樣式 === */
.ai-handoff-btn {
  position: absolute; top: 12px; left: 14px;
  padding: 6px 12px; font-size: 12px; font-weight: 600; color: #6b4423;
  background: rgba(255, 244, 214, 0.85); border: 1px solid rgba(193, 154, 107, 0.55);
  border-radius: 14px; cursor: pointer; transition: .2s ease;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(120, 90, 50, 0.15);
}
.ai-handoff-btn:hover {
  background: rgba(255, 220, 160, 0.95);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(120, 90, 50, 0.25);
}

.ai-bubble-system {
  align-self: center;
  font-size: 12px; color: #8a8a7a; font-style: italic;
  text-align: center; padding: 4px 12px; margin: 4px 0;
  opacity: 0.85;
}

.ai-bubble-human {
  align-self: flex-start;
  background: linear-gradient(135deg, rgba(255, 244, 214, 0.92), rgba(255, 230, 180, 0.85));
  border: 1px solid rgba(193, 154, 107, 0.55);
  border-top-left-radius: 6px;
  box-shadow: 0 8px 24px rgba(180, 130, 60, 0.18);
}
.ai-bubble-human-label {
  font-size: 11px; font-weight: 700; color: #8b5a2b;
  margin-bottom: 6px; letter-spacing: 0.3px;
}

.ai-handoff-suggest {
  align-self: stretch;
  display: flex; flex-direction: column; gap: 10px; align-items: center;
  padding: 14px 18px; margin: 10px 0;
  background: rgba(255, 250, 235, 0.75); border: 1px dashed rgba(193, 154, 107, 0.55);
  border-radius: 14px;
}
.ai-handoff-suggest-text {
  font-size: 13px; color: #6b4423; text-align: center;
}
.ai-handoff-suggest-btn {
  padding: 10px 20px; font-size: 14px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, #c19a6b, #a87a4e); border: none; border-radius: 999px;
  cursor: pointer; transition: .2s ease;
  box-shadow: 0 6px 16px rgba(168, 122, 78, 0.35);
}
.ai-handoff-suggest-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(168, 122, 78, 0.45);
}
/* === 🛒 聊天內加購按鈕 === */
.hh-ai-addcart {
  margin-top: 10px;
  padding: 8px 14px;
  width: 100%;
  border: 1px solid rgba(122, 154, 124, 0.55);
  border-radius: 10px;
  background: linear-gradient(135deg, #7a9a7c, #5f7f63);
  color: #fffdf6;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.22s ease;
  box-shadow: 0 4px 12px rgba(95, 127, 99, 0.28);
}
.hh-ai-addcart:hover {
  transform: translateY(-1px);
  box-shadow: 0 7px 16px rgba(95, 127, 99, 0.38);
  filter: brightness(1.05);
}
.hh-ai-addcart:active { transform: translateY(0); }
.hh-ai-addcart-done {
  background: linear-gradient(135deg, #b8995c, #a3854a);
  border-color: rgba(184, 153, 92, 0.6);
}

/* === ⚡ 串流打字機文字 === */
.hh-stream-text {
  white-space: pre-wrap;
  line-height: 1.65;
}
.hh-stream-text::after {
  content: "▍";
  margin-left: 1px;
  color: #7a9a7c;
  animation: hh-caret-blink 0.9s steps(2) infinite;
}
@keyframes hh-caret-blink {
  50% { opacity: 0; }
}

/* === ✨ 2026-06-11 聊天美化：卡片質感 + 入場動效 === */
.ai-bubble {
  animation: hh-bubble-in 0.28s cubic-bezier(0.22, 0.8, 0.36, 1) both;
}
@keyframes hh-bubble-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.hh-ai-prodrow {
  display: flex;
  align-items: center;
  gap: 12px;
}
.hh-ai-prodthumb {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(170, 190, 170, 0.45);
  box-shadow: 0 3px 8px rgba(120, 150, 110, 0.18);
}
.hh-ai-prodinfo { min-width: 0; }
.hh-ai-price {
  font-size: 0.86rem;
  font-weight: 700;
  color: #5f7f63;
  letter-spacing: 0.03em;
  margin-top: 1px;
}
/* 「阿興師的話」：推薦敘事獨立成一段，不再塞進第一個商品卡（桌機/手機共用）。 */
.ai-reco-note {
  margin: 4px 2px 12px;
  font-size: 0.95rem;
  line-height: 1.85;
  color: #3c4a3a;
}
.ai-reco-note p { margin: 0 0 8px; }
.ai-reco-note p:last-child { margin: 0; }
.ai-reco-note strong { color: #2f4b33; font-weight: 700; }
.ai-reco-note ul, .ai-reco-note ol { margin: 6px 0; padding-left: 20px; }
/* 商品卡之間留間距（移除舊的 inline 側邊條後改用這個） */
.ai-prod-item + .ai-prod-item { margin-top: 8px; }
/* 次推薦若有短理由：和標頭用細線隔開 */
.prod-reason {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid rgba(170, 190, 170, 0.38);
  font-size: 0.88rem;
  line-height: 1.75;
  color: #4f5c46;
}
.ai-option-btn {
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.ai-option-btn:hover { transform: translateY(-1.5px); box-shadow: 0 6px 14px rgba(120, 150, 110, 0.22); }
.ai-option-btn:active { transform: translateY(0) scale(0.97); }
.ai-prod-item { animation: hh-bubble-in 0.32s 0.05s cubic-bezier(0.22, 0.8, 0.36, 1) both; }
@media (prefers-reduced-motion: reduce) {
  .ai-bubble, .ai-prod-item { animation: none; }
  .hh-stream-text::after { animation: none; }
}

/* 觸控目標批次修（2026-07-04 健檢 backlog） */
.ai-option-btn { min-height: 44px; }
.ai-handoff-btn { min-height: 44px; }
.secret-qty-btn { position: relative; }
.secret-qty-btn::after { content: ""; position: absolute; inset: -7px; border-radius: 50%; }

/* 2026-07-04 健檢修：聊天區捲動不外漏到背景（iOS 捲到頂/底手勢） */
.ai-chat-area { overscroll-behavior: contain; }

/* ── 🔐 AI 需登入閘門（2026-07-15）：米白卡＋金髮絲線，LINE 綠 CTA ── */
.ai-login-gate {
  box-sizing: border-box;
  margin: 28px auto;
  max-width: 340px;
  padding: 28px 24px 22px;
  text-align: center;
  background: #faf7f0;
  border: 1px solid rgba(176, 125, 35, 0.28);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(40, 52, 42, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
.ai-login-gate-ico { font-size: 34px; line-height: 1; margin-bottom: 10px; }
.ai-login-gate-title {
  margin: 0 0 10px;
  font-family: "Noto Serif TC", "Noto Serif TC Fallback", serif;
  font-size: 17px; font-weight: 700; letter-spacing: 0.06em;
  color: #3a4a3c;
}
.ai-login-gate-desc {
  margin: 0 0 18px;
  font-size: 13.5px; line-height: 1.75; letter-spacing: 0.02em;
  color: rgba(58, 74, 60, 0.78);
  text-align: left;
}
.ai-login-gate-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  box-sizing: border-box; /* 無全域 border-box：width:100%＋padding 會溢出卡片（2026-07-15 業主回報） */
  width: 100%; max-width: 100%; padding: 13px 18px;
  border-radius: 12px;
  background: #06c755; color: #fff;
  font-size: 15px; font-weight: 700; letter-spacing: 0.04em;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(6, 199, 85, 0.28);
}
.ai-login-gate-btn:active { transform: translateY(1px); }
.ai-login-gate-hint {
  margin: 12px 0 0;
  font-size: 12px; color: rgba(58, 74, 60, 0.55); letter-spacing: 0.03em;
}
.ai-login-gate-alt { margin-top: 6px; }
/* 閘門時輸入列停用視覺 */
.ai-box.ai-gated .ai-input-row { opacity: 0.45; pointer-events: none; }
.ai-box.ai-gated #aiHandoffBtn { opacity: 0.45; pointer-events: none; }

/* ── 📖 延伸閱讀（AI 文章推薦卡，2026-07-30）────────────────────────────
   後端 payload.articles 一直有送，網站端過去沒渲染（只有 LINE 有卡）。
   刻意做「細長書籤條」不做商品卡：延伸閱讀是配角，不跟茶款卡搶視線。
   分類色由 JS 以 inline --tea 帶進來（同專欄頁茶湯色語彙）。 */
/* width:100%（配 .ai-bubble 的 max-width:90%）＝一篇/兩篇的卡寬一致；
   否則單篇時泡泡縮成內容寬，右上箭頭會擠在標題旁邊。 */
.hh-ai-arts { padding: 14px 14px 8px; width: 100%; box-sizing: border-box; }
.hh-ai-art {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 4px 12px;
  text-decoration: none; color: inherit;
  border-bottom: 1px solid rgba(170, 190, 170, 0.30);
  /* hover 的位移用 transform 不用 padding（padding 動畫會觸發 layout） */
  transition: background .2s ease, transform .2s cubic-bezier(.2, .7, .3, 1);
}
.hh-ai-art:last-child { border-bottom: 0; }
.hh-ai-art:hover { background: rgba(255, 255, 240, 0.55); transform: translateX(4px); }
.hh-ai-art:active { background: rgba(255, 255, 240, 0.75); }
.hh-ai-art-body { display: block; min-width: 0; flex: 1; }
.hh-ai-art-meta {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; letter-spacing: 0.08em;
  color: var(--tea, #2f4b3c); opacity: 0.85;
}
.hh-ai-art-meta::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--tea, #2f4b3c); flex: 0 0 auto;
}
.hh-ai-art-title {
  margin-top: 3px;
  font-family: "Noto Serif TC", "Noto Serif TC Fallback", serif;
  font-size: 14.5px; font-weight: 700; line-height: 1.5;
  color: #2c4433;
  /* 標題是業主自己寫的，實際有「水質軟硬度對泡茶的影響：一杯茶好不好喝，水可能
     佔了一半」這種長度 → 夾兩行，超過省略，書籤條才不會長成一塊卡 */
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden;
}
.hh-ai-art-sum {
  display: block; margin-top: 2px;
  font-size: 12.5px; line-height: 1.6;
  color: rgba(58, 74, 60, 0.68);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hh-ai-art-go {
  flex: 0 0 auto; font-size: 15px;
  color: var(--tea, #2f4b3c); opacity: 0.55;
  transition: transform .2s ease, opacity .2s ease;
}
.hh-ai-art:hover .hh-ai-art-go { opacity: 0.9; transform: translate(1px, -1px); }
@media (prefers-reduced-motion: reduce) {
  .hh-ai-art, .hh-ai-art-go { transition: none; }
  .hh-ai-art:hover, .hh-ai-art:hover .hh-ai-art-go { transform: none; }
}
