html{color-scheme:light}
html[data-theme="night"]{color-scheme:dark}
/* ==========================================================================
   港Call 助手 · 樣式（獨立檔）
   --------------------------------------------------------------------------
   2026-11-02 用家回報：叫車頁（order.html）個助手一啲樣都冇，
   X 變灰框、標題斷行、傳送掣跌到下一行。

   原因：order.html 只載入 /order.css，但助手全部 .ai-* 規則本來寫喺
   /styles.css 入面，所以一項都冇生效；而 order.css 嘅變數叫 --card2，
   同 --card-2 對唔上，直接叫佢載 styles.css 又會撞其他樣式。

   所以抽成呢一份獨立檔：唔靠任何頁面變數，每個 var() 都有 fallback，
   五頁一齊掛就一定有樣。
   ========================================================================== */

.ai-box { margin-top: 18px; }

.ai-toggle {
  width: 100%; display: flex; align-items: center; gap: 11px; padding: 12px 14px;
  border-radius: 14px; cursor: pointer; text-align: left; font-family: inherit;
  background: rgba(47, 211, 155, .08); border: 1px solid rgba(47, 211, 155, .3);
  color: var(--text, #eef3fb);
}
.ai-toggle:active { background: rgba(47, 211, 155, .14); }

.ai-avatar {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-size: 19px;
  background: linear-gradient(135deg, #1d6f5c, #16513f);
  border: 1px solid rgba(47, 211, 155, .45);
}
.ai-avatar.sm { width: 30px; height: 30px; font-size: 16px; }

.ai-toggle-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ai-toggle-txt b { font-size: 14px; font-weight: 700; }
.ai-toggle-txt i { font-size: 11.5px; font-style: normal; color: var(--muted, #93a2bd); }

/* ---- 面板 ---- */
.ai-panel {
  margin-top: 10px; border-radius: 16px;
  background: var(--card-2, var(--card2, #18243d));
  border: 1px solid var(--line, #24314b); overflow: hidden;
}

.ai-head {
  display: flex; align-items: center; gap: 10px; padding: 11px 13px;
  border-bottom: 1px solid var(--line, #24314b);
  background: rgba(255, 255, 255, .02);
}
.ai-head-txt { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.ai-head-txt b {
  font-size: 13.5px; font-weight: 700;
  color: var(--text, #eef3fb); white-space: nowrap;
}
.ai-head-txt i { font-size: 10.5px; font-style: normal; color: var(--muted, #93a2bd); }

.ai-close {
  flex: none; width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  background: transparent; border: 0; color: var(--muted, #93a2bd); font-size: 15px;
  font-family: inherit; line-height: 1;
  display: grid; place-items: center;
}
.ai-close:active { background: rgba(255, 255, 255, .06); }

.ai-log {
  display: flex; flex-direction: column; gap: 8px;
  padding: 13px; max-height: 300px; overflow-y: auto;
  overscroll-behavior: contain;
}
.ai-msg {
  max-width: 84%; padding: 9px 12px; border-radius: 14px;
  font-size: 13.5px; line-height: 1.55; word-break: break-word;
  animation: ai-in .18s ease-out;
}
.ai-msg.bot {
  align-self: flex-start; background: var(--card, #16232f);
  border: 1px solid var(--line, #24314b);
  border-bottom-left-radius: 5px; color: var(--text, #eef3fb);
}
.ai-msg.me {
  align-self: flex-end; color: #062018;
  background: linear-gradient(135deg, #2fd39b, #2fd39b);
  border-bottom-right-radius: 5px; font-weight: 550;
}
@keyframes ai-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.ai-chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 13px 11px; }
.ai-chips:empty { padding: 0; }
.ai-chips button {
  padding: 7px 12px; font-size: 12px; font-family: inherit; cursor: pointer;
  color: #a9e8d6; background: rgba(47, 211, 155, .09);
  border: 1px solid rgba(47, 211, 155, .28); border-radius: 999px;
}
.ai-chips button:active { background: rgba(47, 211, 155, .18); }

/* 輸入區：一定要 flex 一行過，唔好俾瀏覽器預設樣式拆開 */
.ai-form {
  display: flex; align-items: center; gap: 8px; padding: 11px 13px;
  border-top: 1px solid var(--line, #24314b); background: rgba(0, 0, 0, .14);
  margin: 0;
}
.ai-form input {
  flex: 1 1 auto; min-width: 0; width: auto; margin: 0;
  padding: 10px 12px; font-size: 16px;
  color: var(--text, #eaf2f7); background: var(--card, #16232f);
  border: 1.5px solid var(--line, #24314b); border-radius: 11px;
  outline: none; font-family: inherit;
  -webkit-appearance: none; appearance: none;
}
.ai-form input:focus { border-color: var(--accent, #2fd39b); }
.ai-form input::placeholder { color: #5f7196; }

/* 等客人打問題時：整條輸入列亮起，指明「就喺呢度打」。
   2026-11-05 用家回報：只叫客人打字，但佢唔知打喺邊。 */
.ai-form.ai-form-arm {
  background: rgba(47, 211, 155, .09);
  border-top-color: rgba(47, 211, 155, .45);
}
.ai-form.ai-form-arm input {
  border-color: var(--accent, #2fd39b);
  box-shadow: 0 0 0 3px rgba(47, 211, 155, .18);
  animation: aiArmPulse 1.6s ease-out 3;
}
.ai-form.ai-form-arm input::placeholder { color: #9fe8d4; }
@keyframes aiArmPulse {
  0%   { box-shadow: 0 0 0 3px rgba(47, 211, 155, .18); }
  50%  { box-shadow: 0 0 0 9px rgba(47, 211, 155, .04); }
  100% { box-shadow: 0 0 0 3px rgba(47, 211, 155, .18); }
}
.ai-form button {
  flex: none; width: auto; margin: 0;
  padding: 10px 16px; border: 0; border-radius: 11px; cursor: pointer;
  background: linear-gradient(135deg, #2fd39b, #2fd39b); color: #062018;
  font-size: 13.5px; font-weight: 750; font-family: inherit;
  -webkit-appearance: none; appearance: none;
}
.ai-form button:disabled { opacity: .5; }

/* ---- 浮動頭像掣 ---- */
.ai-fab-wrap { position: fixed; right: 0; bottom: 0; z-index: 900; margin: 0; }

.ai-fab {
  position: fixed;
  /* 貼右邊、喺地圖區，唔會撞到底部嘅「確認叫車」 */
  right: 10px;
  top: 26%;
  transform: translateY(-50%);
  width: 48px; height: 48px; padding: 0; border: 0; border-radius: 50%;
  cursor: pointer; display: grid; place-items: center;
  background: linear-gradient(135deg, #1d6f5c, #16513f);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45), 0 0 0 1px rgba(47, 211, 155, .4);
  transition: transform .16s ease, box-shadow .16s ease;
  z-index: 900;
  /* 2026-11-03 修正「好難拖」：
     冇 touch-action 嘅話，Android Chrome 會當手指移動係「滑動頁面」，
     一拖就搶走手勢並發 pointercancel，所以只可以拖到一兩格就斷。
     設 none 之後，手勢完全交返我哋嘅 pointermove 處理。
     user-select / -webkit-user-drag 防止長按彈出選字同拖圖。 */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-tap-highlight-color: transparent;
}
.ai-fab .ai-avatar {
  width: 100%; height: 100%; font-size: 22px;
  background: transparent; border: 0;
}
.ai-fab:active { transform: translateY(-50%) scale(.94); }

/* 返到叫車頁自動走出嚟：由細慢慢彈大，唔會突然彈出嚇一跳 */
@keyframes aiFabIn {
  from { opacity: 0; transform: translateY(-50%) scale(.5); }
  to   { opacity: 1; transform: translateY(-50%) scale(1); }
}
@keyframes aiFabInMoved {
  from { opacity: 0; transform: scale(.5); }
  to   { opacity: 1; transform: scale(1); }
}
.ai-fab.ai-fab-enter { animation: aiFabIn .44s cubic-bezier(.22, 1.25, .36, 1); }
.ai-fab.moved.ai-fab-enter { animation-name: aiFabInMoved; }

.ai-fab-dot {
  position: absolute; top: 2px; right: 2px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--accent, #2fd39b);
  border: 2px solid var(--bg, #0d1620);
}
.ai-fab-wrap.open .ai-fab { display: none; }

/* 拖動過之後用 left/top 定位，唔再用 right + translateY */
.ai-fab.moved { right: auto; top: auto; transform: none; }
.ai-fab.moved:active { transform: scale(.94); }
.ai-fab.dragging {
  transition: none;
  cursor: grabbing;
  transform: scale(1.06);
  box-shadow: 0 14px 36px rgba(0,0,0,.7), 0 0 0 2px rgba(47,211,155,.75);
}
body.ai-dragging { user-select: none; -webkit-user-select: none; }

/* 拖到底部呢條紅色虛線區放手就會收起 */
.ai-fab-zone {
  position: fixed; left: 0; right: 0; bottom: 0; height: 76px;
  display: none; place-items: center; pointer-events: none;
  background: linear-gradient(to top, rgba(255,107,107,.2), rgba(255,107,107,0));
  border-top: 1.5px dashed rgba(255,107,107,.6);
  color: #ffb4b4; font-size: 12px; letter-spacing: .5px;
  z-index: 902;
}
body.ai-dragging .ai-fab-zone { display: grid; }

/* 收起之後留低嘅細圓點，撳一下叫返助手出嚟 */
.ai-fab-ghost {
  position: fixed; z-index: 900;
  right: 8px; bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  width: 32px; height: 32px; padding: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  font-size: 15px; opacity: .5;
  background: var(--card-2, var(--card2, #1b2a38)); color: var(--accent, #2fd39b);
  border: 1px solid rgba(47,211,155,.32);
}
.ai-fab-ghost:active { opacity: .95; }

/* 面板一律做底部浮層：對話再長，輸入框都貼住底部，永遠撳得到「傳送」 */
.ai-panel,
.ai-panel-fab {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  margin: 0; z-index: 901;
  max-height: min(76vh, 580px);
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}
.ai-panel .ai-log,
.ai-panel-fab .ai-log { flex: 1; max-height: none; min-height: 120px; }

/* 面板打開時鎖住背景捲動 */
body.ai-open { overflow: hidden; }

.hidden { display: none !important; }

/* 桌面版：右邊係固定面板，浮掣要讓開，否則會疊喺面板上面 */
@media (min-width: 720px) {
  .ai-fab { right: 440px; top: 50%; }
  .ai-panel,
  .ai-panel-fab {
    left: auto; right: 24px; width: 400px;
    bottom: 24px;
  }
}

/* ==========================================================================
   緊湊通知卡（2026-11-04 用家要求）
   --------------------------------------------------------------------------
   用家回報：落單後機械人彈出成個對話框，遮住半個畫面，太阻礙。
   所以通知唔再開面板，改為底部一張細卡：
     · 只佔底部一小條，唔會蓋住地圖同「確認叫車」
     · 最多顯示三行，多的話自動截斷
     · 撳一下卡片才展開完整對話
     · 有彈入動畫、震動、響鈴
   ========================================================================== */

.ai-note {
  position: fixed;
  /* 2026-11-05 用家指示：機器人彈出嘅通知卡要「大一點」。
     之前為咗似師傅台而收得太窄（232px），字細到睇唔清。
     改為按內容自適應，最闊 340px／九成畫面，手機上一眼睇得完。 */
  left: auto;
  right: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  width: max-content;
  max-width: min(92vw, 340px);
  min-width: 200px;
  z-index: 903;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 13px;
  border-radius: 16px;
  /* 2026-11-21 用家：「港call助手的小藍框 要跟隨乘客司機主題黑」。
     原本寫死深藍漸變 #1b2a38→#16232f，同全站黑灰對不上。
     改用主題卡色，日／夜都由 data-theme 決定，唔再各自一套。 */
  background: var(--card-2, var(--card2, #1b2a38));
  border: 1px solid var(--line, #26384a);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .55), 0 0 0 1px rgba(0, 0, 0, .25);
  color: var(--text, #eaf2f7);
  cursor: pointer;
  /* 由機身右邊打橫滑入（用家 2026-11-05 要求），帶少少回彈。
     用 translateX(110%) 起步，確保完全喺畫面外，唔會偷步見到。 */
  animation: aiNoteIn .52s cubic-bezier(.16, 1.28, .3, 1) both;
  will-change: transform, opacity;
}

@keyframes aiNoteIn {
  0%   { opacity: 0; transform: translateX(110%) scale(.97); }
  55%  { opacity: 1; transform: translateX(-7px) scale(1.008); }
  75%  { opacity: 1; transform: translateX(4px) scale(1); }
  90%  { opacity: 1; transform: translateX(-2px) scale(1); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}

.ai-note.out,
.ai-note.dragged.out {
  animation: aiNoteOut .26s cubic-bezier(.4, 0, 1, 1) forwards;
  pointer-events: none;
}
/* 收起時原路滑返右邊出去 */
@keyframes aiNoteOut {
  0%   { opacity: 1; transform: translateX(0) scale(1); }
  100% { opacity: 0; transform: translateX(110%) scale(.96); }
}

/* 頂部一條會流動嘅光帶，提示「有新消息」 */
.ai-note::before {
  content: '';
  position: absolute; left: 14px; right: 14px; top: 0; height: 2px;
  border-radius: 0 0 2px 2px;
  background: linear-gradient(90deg, transparent, #2fd39b, transparent);
  background-size: 200% 100%;
  animation: aiNoteSweep 1.6s linear infinite;
}
@keyframes aiNoteSweep {
  from { background-position: -100% 0; }
  to   { background-position: 200% 0; }
}

.ai-note .ai-note-avatar {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; font-size: 17px;
  background: linear-gradient(135deg, #1d6f5c, #16513f);
  border: 1px solid rgba(47, 211, 155, .5);
  box-shadow: 0 0 0 0 rgba(47, 211, 155, .5);
  animation: aiNotePulse 1.8s ease-out 2;
}
@keyframes aiNotePulse {
  0%   { box-shadow: 0 0 0 0 rgba(47, 211, 155, .55); }
  70%  { box-shadow: 0 0 0 11px rgba(47, 211, 155, 0); }
  100% { box-shadow: 0 0 0 0 rgba(47, 211, 155, 0); }
}

.ai-note .ai-note-body { flex: 1; min-width: 0; }

.ai-note .ai-note-title {
  font-size: 14px; font-weight: 800; letter-spacing: .2px;
  color: var(--accent, #2fd39b); margin-bottom: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.ai-note .ai-note-text {
  font-size: 14px; line-height: 1.45;
  /* 一句起兩句止，超出用 … 截斷 */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}

.ai-note .ai-note-more {
  margin-top: 4px; font-size: 11.5px; color: var(--muted, #8ea3b2);
}

.ai-note .ai-note-x {
  flex: none; width: 24px; height: 24px; padding: 0;
  border: 0; border-radius: 50%; cursor: pointer;
  background: transparent; color: var(--muted, #8ea3b2); font-size: 17px;
  display: grid; place-items: center; font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.ai-note .ai-note-x:active { background: rgba(127, 140, 152, .16); }

/* 尊重系統「減少動態效果」設定 */
@media (prefers-reduced-motion: reduce) {
  .ai-note, .ai-note::before, .ai-note .ai-note-avatar { animation: none; }
}

/* ---- 卡片可以拖動擺位（2026-11-05 用家要求） ----
   預設貼底部；拖過之後改用 left/top 定位，位置記入 localStorage，
   下次通知喺同一個位彈出，唔使每次都搬。 */
.ai-note {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.ai-note.dragged {
  left: auto; right: auto; bottom: auto;
  /* 拖動時唔好再播入場動畫，否則會拉返原位 */
  animation: none;
  cursor: grabbing;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .7), 0 0 0 1px rgba(47, 211, 155, .55);
  transform: scale(1.02);
  transition: none;
}


/* ==========================================================================
   2026-11-28 用家：「港Call 助手」下面啲字太淡，睇唔清。
   --------------------------------------------------------------------------
   根因：.ai-chips button 嘅字色寫死 #a9e8d6（原本深色主題用嘅淺綠），
   但 /app、/track、/order 三頁已經全部係白底，
   淺綠字落淺灰綠底 = 對比度 1.2:1，等於隱形。
   輸入框提示字 #5f7196 同樣係深色主題嘅值。

   做法：預設（淺底）用深綠／深灰；夜間頁（home.html）另外覆寫返原本淺色。
   淺底對比度：快速提問 5.9:1、副標題 5.8:1、提示字 5.2:1（全部過 4.5:1）。
   ========================================================================== */
.ai-chips button {
  color: #0a6b52;
  background: rgba(11, 143, 109, .10);
  border-color: rgba(11, 143, 109, .32);
}
.ai-chips button:active { background: rgba(11, 143, 109, .20); }
.ai-head-txt i { color: #4a5c65; }
.ai-form { background: rgba(16, 28, 38, .045); }
.ai-form input::placeholder { color: #5d7078; }
.ai-form.ai-form-arm input::placeholder { color: #0a6b52; }

/* 夜間頁維持原本淺色（深底淺字） */
html[data-theme="night"] .ai-chips button {
  color: #a9e8d6; background: rgba(47, 211, 155, .09);
  border-color: rgba(47, 211, 155, .28);
}
html[data-theme="night"] .ai-chips button:active { background: rgba(47, 211, 155, .18); }
html[data-theme="night"] .ai-head-txt i { color: var(--muted, #93a2bd); }
html[data-theme="night"] .ai-form { background: rgba(0, 0, 0, .14); }
html[data-theme="night"] .ai-form input::placeholder { color: #5f7196; }
html[data-theme="night"] .ai-form.ai-form-arm input::placeholder { color: #9fe8d4; }
