/* Studio 工具頁 ≤768 的底部聊天列(spec designer chat-mobile-entry-2026-12-01,B 版):固定在底、48 高,
   最新一則的預覽加未讀膠囊,整列進聊天頁那間房。markup common/chat_mbar.html、行為 js/chat_mbar.js。
   畫不畫由 html.mbar-on 決定(chat_mbar.js);≥769 與橫拿(視窗高 <420,也是 Android 鍵盤升起時)整個不顯示。
   區域筆記 docs/notes/chat-cue.md › 手機的聊天列 */
#chat_mbar {
  display: none;
}

@media (max-width: 768px) and (min-height: 420px) {
  html.mbar-on {
    --mbar-h: calc(48px + env(safe-area-inset-bottom, 0px));
    /* 鍵盤 Tab 到被列蓋住的元素時,捲到列的上方(WCAG 2.4.11) */
    scroll-padding-bottom: var(--mbar-h);
  }

  /* 內容區多留一列高,頁尾不被蓋住 */
  html.mbar-on body {
    padding-bottom: var(--mbar-h);
  }

  /* 貼底的 toast 往上讓一列(站方動態的 #hl_toast、儀表板存檔失敗、台股自選股) */
  html.mbar-on :is(#hl_layer .chat_toast, .dd_toast, .tw-toast) {
    bottom: calc(var(--space-24) + var(--mbar-h));
  }

  /* 頁尾在 landing/base.css 是 z-index 999(比頂列面板的遮罩 998 還高),會蓋住這一列、搶走點擊。
     列畫著時把頁尾降到內容那一層:它自己的堆疊層還在,只是不再壓過固定的列與遮罩 */
  html.mbar-on footer {
    z-index: 1;
  }

  /* 高過頁面內容與頁尾,低於頂列面板的遮罩 .overlay(998)、搜尋、modal、offcanvas、選股器的底部面板 */
  #chat_mbar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    display: flex;
    align-items: flex-start;
    box-sizing: border-box;
    height: calc(48px + env(safe-area-inset-bottom, 0px));
    /* 跟頂列同一條 350 欄;✕ 是 28 的 icon 鈕,右邊多讓 12,圖示對齊欄的右緣一帶(同 mockup) */
    padding: 0 max(var(--space-8), calc((100% - 350px) / 2 - var(--space-12))) 0 max(20px, calc((100% - 350px) / 2));
    background: var(--surface-card);
    box-shadow: var(--shadow-md);
    visibility: hidden;
    transform: translateY(100%);
    transition:
      transform calc(var(--motion-travel) * 0.7) var(--ease-standard),
      visibility 0s linear calc(var(--motion-travel) * 0.7);
  }

  html.mbar-on #chat_mbar {
    visibility: visible;
    transform: none;
    transition: transform var(--motion-travel) var(--ease-standard);
  }

  #chat_mbar .mbar_a {
    display: flex;
    flex: 1;
    align-items: center;
    gap: var(--space-8);
    min-width: 0;
    height: 48px;
    color: var(--ink);
    font-size: 13px;
    line-height: 20px;
    text-decoration: none;
    /* 列貼著視窗邊,往外的焦點框會被切掉 */
    outline-offset: -2px;
  }

  #chat_mbar .mbar_a > .ico {
    width: 20px;
    height: 20px;
    color: var(--ink-2);
  }

  #chat_mbar .mbar_n {
    flex: none;
    font-weight: 600;
  }

  #chat_mbar .mbar_p {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    color: var(--ink-3);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #chat_mbar .mbar_p.un {
    color: var(--ink);
  }

  #chat_mbar .mbar_p.sup {
    color: var(--ink);
    font-weight: 600;
  }

  /* 未讀膠囊是 studio/chat/main.css 的 .chat_pill(右欄的 partial 載入,這一列跟它同頁) */

  /* ✕:外觀 28 的 icon 鈕,熱區用 ::before 補到 44×44;左邊的 8 剛好是熱區的外擴,不疊到連結 */
  #chat_mbar .mbar_x {
    position: relative;
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin: 10px 0 10px var(--space-8);
    padding: 0;
    border: 0;
    border-radius: var(--radius-xs);
    background: none;
    color: var(--ink-2);
    transition:
      background-color var(--motion-fast) var(--ease-standard),
      color var(--motion-fast) var(--ease-standard);
  }

  #chat_mbar .mbar_x::before {
    content: "";
    position: absolute;
    inset: calc(-1 * var(--space-8));
  }

  #chat_mbar .mbar_x .ico {
    width: 16px;
    height: 16px;
  }

  @media (hover: hover) {
    #chat_mbar .mbar_x:hover {
      background: var(--surface-muted);
      color: var(--ink);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  #chat_mbar,
  html.mbar-on #chat_mbar,
  #chat_mbar .mbar_x {
    transition: none;
  }
}
