/* =====================================================================
   wms-demo-ai：AI 理專助理（SYSCLAW）樣式
   - 沿用 wms-demo 元大藍漸層＋金色點綴的色票（--grad-brand、--c-accent、--c-gold）
   - 寬螢幕（≥1280px）對話窗固定在右側，系統畫面與客戶首頁視窗自動讓出空間
   ===================================================================== */
:root { --ai-w: 420px; --ai-gap: 16px; }

/* ---------- 浮動按鈕 ---------- */
.ai-fab { position: fixed; right: 24px; bottom: 24px; z-index: 47; display: inline-flex; align-items: center; gap: 8px; height: 52px; padding: 0 20px 0 16px;
  border: 0; border-radius: 999px; background: var(--grad-brand); color: #fff; font: inherit; font-size: 15px; font-weight: 700; letter-spacing: .02em; cursor: pointer;
  box-shadow: 0 12px 28px rgba(4, 30, 80, .35), inset 0 -3px 0 var(--c-gold); transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
  animation: aiFabIn .6s cubic-bezier(.34, 1.4, .5, 1) .4s both; }
.ai-fab svg { width: 22px; height: 22px; fill: var(--c-gold); stroke: none; }
.ai-fab::before { content: ""; position: absolute; inset: -4px; border-radius: inherit; border: 2px solid var(--c-gold); opacity: 0; animation: aiRing 2.4s ease-out 1.2s 2; pointer-events: none; }
.ai-fab:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(4, 30, 80, .42), inset 0 -3px 0 var(--c-gold); }
.ai-fab:focus-visible { outline: 3px solid var(--c-gold); outline-offset: 3px; }
#aiDock.is-open .ai-fab { opacity: 0; transform: scale(.85); pointer-events: none; }
@keyframes aiFabIn { from { opacity: 0; transform: translateY(20px) scale(.9); } }
@keyframes aiRing { 0% { opacity: .9; transform: scale(1); } 100% { opacity: 0; transform: scale(1.35); } }

/* ---------- 對話窗 ---------- */
.ai-panel { position: fixed; right: var(--ai-gap); top: var(--ai-gap); bottom: var(--ai-gap); z-index: 48; width: var(--ai-w); display: flex; flex-direction: column;
  background: #fff; border-radius: 18px; overflow: hidden; box-shadow: 0 24px 64px rgba(4, 30, 80, .32), 0 0 0 1px rgba(10, 44, 102, .06);
  opacity: 0; transform: translateX(24px); transition: opacity .22s ease, transform .28s cubic-bezier(.22, .61, .36, 1); }
.ai-panel.is-open { opacity: 1; transform: none; }
.ai-panel[hidden] { display: none; }
.ai-panel svg { flex-shrink: 0; }

.ai-head { position: relative; display: flex; align-items: center; gap: 10px; padding: 14px 12px 14px 16px; background: var(--grad-brand); color: #fff; flex-shrink: 0; }
.ai-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, var(--c-gold), rgba(232, 184, 74, 0)); }
.ai-head__logo { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: rgba(255, 255, 255, .14); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22); }
.ai-head__logo svg { width: 22px; height: 22px; fill: var(--c-gold); stroke: none; }
.ai-head__t { flex: 1; min-width: 0; line-height: 1.3; }
.ai-head__t b { display: block; font-size: 16px; letter-spacing: .02em; }
.ai-head__t small { display: block; font-size: 12px; color: rgba(255, 255, 255, .78); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-head__btn { width: 34px; height: 34px; border: 0; border-radius: 10px; background: none; color: #fff; display: grid; place-items: center; cursor: pointer; }
.ai-head__btn:hover { background: rgba(255, 255, 255, .14); }
.ai-head__btn svg { width: 18px; height: 18px; }

/* 目前客戶 */
.ai-ctx { padding: 10px 12px 10px; background: linear-gradient(180deg, var(--c-accent-soft), #fff); border-bottom: 1px solid var(--c-border); flex-shrink: 0; }
.ai-ctx[hidden] { display: none; }
.ai-ctx__who { display: flex; align-items: center; gap: 4px; }
.ai-ctx__pick { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border: 0; border-radius: 12px; background: none;
  font: inherit; text-align: left; color: inherit; cursor: pointer; transition: background .15s ease; }
.ai-ctx__pick:hover, .ai-ctx__pick[aria-expanded="true"] { background: rgba(10, 44, 102, .06); }
.ai-ctx__pick:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(0, 114, 198, .28); }
.ai-ctx__av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--grad-brand); color: #fff; font-weight: 700;
  box-shadow: 0 0 0 2px var(--c-gold); flex-shrink: 0; }
.ai-ctx__av svg { width: 17px; height: 17px; }
.ai-ctx__pick.is-empty .ai-ctx__av { background: #fff; color: var(--c-accent-hover); box-shadow: inset 0 0 0 1.5px var(--c-accent-border); }
.ai-ctx__t { flex: 1; min-width: 0; line-height: 1.3; }
.ai-ctx__t b { display: flex; align-items: center; gap: 3px; font-size: 14.5px; color: var(--c-ink); }
.ai-ctx__pick.is-empty .ai-ctx__t b { color: var(--c-accent-hover); }
.ai-ctx__t b svg { width: 14px; height: 14px; color: var(--c-slate-400); flex-shrink: 0; }
.ai-ctx__t small { display: block; font-size: 12px; color: var(--c-slate-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-ctx__x { width: 28px; height: 28px; border: 0; border-radius: 8px; background: none; color: var(--c-slate-500); display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
.ai-ctx__x:hover { background: rgba(10, 44, 102, .06); } .ai-ctx__x svg { width: 15px; height: 15px; }
.ai-ctx__fold { display: inline-flex; align-items: center; gap: 2px; height: 28px; padding: 0 4px 0 8px; border: 0; border-radius: 8px; background: none; flex-shrink: 0;
  color: var(--c-accent-hover); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.ai-ctx__fold:hover { background: rgba(10, 44, 102, .06); }
.ai-ctx__fold svg { width: 14px; height: 14px; transition: transform .2s ease; }
.ai-ctx__fold[aria-expanded="true"] svg { transform: rotate(180deg); }

/* 約訪三階段快捷鍵：約訪前／約訪中／約訪後 三欄，各 3 顆（客戶首頁「問 AI」卡、對話窗客戶卡） */
.ai-kit { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ai-kit__col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ai-kit__ph { display: flex; align-items: center; gap: 6px; margin: 0 0 1px; font-size: 12px; font-weight: 700; color: var(--c-navy); letter-spacing: .04em; }
.ai-kit__ph i { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; font-style: normal; font-size: 10.5px; letter-spacing: 0;
  color: #fff; background: var(--grad-brand); box-shadow: 0 0 0 2px rgba(232, 184, 74, .6); }
.ai-kit__btn { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 32px; padding: 5px 8px 5px 10px; border: 1px solid var(--c-accent-border); border-radius: 10px;
  background: #fff; color: var(--c-accent-hover); font: inherit; font-size: 12.5px; font-weight: 600; line-height: 1.25; text-align: left; cursor: pointer;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease; }
.ai-kit__btn span { flex: 1; min-width: 0; }
.ai-kit__btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.ai-kit__btn .ai-kit__mode { width: 13px; height: 13px; color: var(--c-slate-400); }
.ai-kit__btn:hover { background: var(--c-accent-soft); border-color: var(--c-accent); }
.ai-kit__btn:hover .ai-kit__mode { color: var(--c-accent-hover); }
.ai-kit__btn:focus-visible { outline: none; border-color: var(--c-accent); box-shadow: 0 0 0 3px rgba(0, 114, 198, .28); }
.ai-kit__btn[aria-expanded="true"] { background: var(--c-accent-soft); border-color: var(--c-accent); }
.ai-ctx .ai-kit { margin-top: 8px; gap: 6px; }
.ai-ctx__legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px 12px; margin: 6px 2px 0; font-size: 11px; color: var(--c-slate-500); }
.ai-ctx__legend span { display: inline-flex; align-items: center; gap: 3px; }
.ai-ctx__legend svg { width: 11px; height: 11px; color: var(--c-slate-400); }
/* 對話窗、手機比較窄：不放前面的圖示，填入／選商品的小圖示移到右上角，讓文字一行放得下 */
.ai-ctx .ai-kit__ic { display: none; }
.ai-ctx .ai-kit__btn { position: relative; min-height: 30px; padding: 4px 13px 4px 8px; font-size: 12px; }
.ai-ctx .ai-kit__btn .ai-kit__mode { position: absolute; top: 4px; right: 4px; width: 10px; height: 10px; }
/* 三欄對齊：標題列與每一列按鈕跨欄同高（瀏覽器支援 subgrid 時） */
@supports (grid-template-rows: subgrid) {
  .ai-kit { grid-template-rows: repeat(4, auto); }
  .ai-kit__col { display: grid; grid-row: span 4; grid-template-rows: subgrid; }
}

/* 對話內容 */
.ai-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 14px 8px; background: var(--c-bg-page); display: flex; flex-direction: column; gap: 14px; }
.ai-msg { display: flex; gap: 8px; align-items: flex-start; animation: aiMsgIn .35s cubic-bezier(.22, .61, .36, 1) both; }
@keyframes aiMsgIn { from { opacity: 0; transform: translateY(8px); } }
.ai-msg--me { justify-content: flex-end; }
.ai-msg--me .ai-bub { max-width: 86%; padding: 9px 13px; border-radius: 14px 14px 4px 14px; background: var(--grad-brand); color: #fff; font-size: 14px; line-height: 1.55; box-shadow: 0 4px 12px rgba(4, 30, 80, .18); word-break: break-word; }
.ai-msg--me .ai-cname { color: #fff; text-decoration-color: rgba(255, 255, 255, .6); }
.ai-av { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--grad-brand); box-shadow: inset 0 -2px 0 var(--c-gold); }
.ai-av svg { width: 17px; height: 17px; fill: var(--c-gold); stroke: none; }
.ai-msg--ai .ai-bub { flex: 1; min-width: 0; padding: 11px 13px 9px; border-radius: 4px 14px 14px 14px; background: #fff; border: 1px solid var(--c-border); box-shadow: 0 2px 8px rgba(15, 23, 42, .05); }
.ai-msg--sys { justify-content: center; }
.ai-note { display: flex; gap: 8px; align-items: flex-start; max-width: 92%; padding: 10px 12px; border-radius: 12px; background: #FFF6E5; color: #92400E; font-size: 13px; line-height: 1.55; }
.ai-note svg { width: 16px; height: 16px; margin-top: 2px; }

.ai-steps { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ai-step { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; background: var(--c-accent-soft); color: var(--c-accent-hover); font-size: 12px; font-weight: 600; }
.ai-step.is-done { background: #FBF3DF; color: var(--c-gold-dark); }
.ai-step.is-err { background: #FEE2E2; color: var(--c-danger-dark); }
.ai-spin { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--c-accent-border); border-top-color: var(--c-accent); animation: spin .8s linear infinite; }
.ai-wait { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--c-slate-500); padding: 2px 0 4px; }
.ai-dots { display: inline-flex; gap: 4px; }
.ai-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--c-accent); animation: aiDot 1.2s ease-in-out infinite; }
.ai-dots i:nth-child(2) { animation-delay: .15s; } .ai-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes aiDot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.ai-err { display: flex; align-items: center; gap: 6px; margin-top: 6px; padding: 8px 10px; border-radius: 10px; background: #FEF2F2; color: var(--c-danger-dark); font-size: 13px; }
.ai-err svg { width: 15px; height: 15px; } .ai-err .link { margin-left: auto; color: var(--c-danger-dark); font-weight: 600; }
.ai-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--c-border); font-size: 11.5px; color: var(--c-slate-400); }
.ai-foot__btn { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 2px 4px; border-radius: 6px; font: inherit; font-size: 12px; color: var(--c-slate-500); cursor: pointer; }
.ai-foot__btn:hover { background: var(--c-bg-soft); color: var(--c-accent-hover); } .ai-foot__btn svg { width: 13px; height: 13px; }
.ai-foot span { margin-left: auto; }

/* AI 回覆排版（Markdown） */
.ai-md { font-size: 14px; line-height: 1.7; color: var(--c-slate-700); word-break: break-word; }
.ai-md > :first-child { margin-top: 0; } .ai-md > :last-child { margin-bottom: 0; }
.ai-md p { margin: 0 0 8px; }
.ai-md h4, .ai-md h5 { margin: 12px 0 6px; color: var(--c-ink); line-height: 1.4; }
.ai-md h4 { font-size: 15px; padding-left: 8px; border-left: 3px solid var(--c-gold); } .ai-md h5 { font-size: 14px; }
.ai-md ul, .ai-md ol { margin: 0 0 8px; padding-left: 20px; } .ai-md li { margin: 2px 0; } .ai-md li::marker { color: var(--c-accent); }
.ai-md b { color: var(--c-ink); }
.ai-md code { padding: 1px 5px; border-radius: 5px; background: var(--c-bg-soft); font-size: 12.5px; }
.ai-md pre { margin: 0 0 8px; padding: 10px 12px; border-radius: 10px; background: #0F1E3A; color: #E2E8F0; overflow-x: auto; font-size: 12.5px; line-height: 1.5; }
.ai-md pre code { padding: 0; background: none; color: inherit; }
.ai-md blockquote { margin: 0 0 8px; padding: 6px 10px; border-left: 3px solid var(--c-accent-border); background: var(--c-accent-soft); border-radius: 0 8px 8px 0; color: var(--c-slate-600); }
.ai-md hr { border: 0; border-top: 1px solid var(--c-border); margin: 10px 0; }
.ai-md a { color: var(--c-accent-hover); text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.ai-tbl { margin: 4px 0 10px; overflow-x: auto; border: 1px solid var(--c-border); border-radius: 10px; }
.ai-tbl table { width: 100%; border-collapse: collapse; font-size: 12.5px; line-height: 1.5; }
.ai-tbl th { padding: 7px 9px; text-align: left; white-space: nowrap; background: var(--c-accent-soft); color: var(--c-ink); font-weight: 700; border-bottom: 1px solid var(--c-accent-border); }
.ai-tbl td { padding: 7px 9px; border-top: 1px solid var(--c-border); vertical-align: top; }
.ai-tbl tr:nth-child(even) td { background: #FAFCFE; }
.ai-cname { display: inline; padding: 0 1px; border: 0; background: none; font: inherit; font-weight: 700; color: var(--c-accent-hover); text-decoration: underline dotted; text-underline-offset: 3px; cursor: pointer; }
.ai-cname:hover { color: var(--c-ink); background: var(--c-accent-soft); border-radius: 4px; }

/* 開場：建議提問 */
.ai-hello { display: flex; flex-direction: column; gap: 14px; animation: aiMsgIn .4s ease both; }
.ai-hello__hi { display: flex; gap: 10px; padding: 14px; border-radius: 14px; background: #fff; border: 1px solid var(--c-border); }
.ai-hello__logo { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--grad-brand); flex-shrink: 0; box-shadow: inset 0 -2px 0 var(--c-gold); }
.ai-hello__logo svg { width: 20px; height: 20px; fill: var(--c-gold); stroke: none; }
.ai-hello__hi b { display: block; font-size: 15px; color: var(--c-ink); margin-bottom: 2px; }
.ai-hello__hi p { margin: 0; font-size: 13px; line-height: 1.6; color: var(--c-slate-600); }
.ai-hello__g h4 { margin: 0 0 6px 2px; font-size: 12px; font-weight: 700; color: var(--c-slate-500); letter-spacing: .04em; }
.ai-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-chip { padding: 7px 12px; border: 1px solid var(--c-accent-border); border-radius: 999px; background: #fff; color: var(--c-accent-hover); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s ease, border-color .15s ease, transform .15s ease; }
.ai-chip:hover { background: var(--c-accent-soft); border-color: var(--c-accent); transform: translateY(-1px); }

/* 輸入區 */
.ai-input { flex-shrink: 0; padding: 10px 12px 10px; background: #fff; border-top: 1px solid var(--c-border); }
.ai-input__row { display: flex; align-items: flex-end; gap: 8px; }
.ai-input textarea { flex: 1; min-width: 0; resize: none; max-height: min(220px, 32vh); padding: 10px 12px; border: 1px solid var(--c-border); border-radius: 12px; background: var(--c-bg-page);
  font: inherit; font-size: 16px; line-height: 1.45; color: var(--c-ink); outline: none; transition: border-color .15s ease, box-shadow .15s ease, background .15s ease; }
.ai-input textarea:focus { border-color: var(--c-accent); background: #fff; box-shadow: 0 0 0 3px var(--c-accent-soft); }
@media (min-width: 641px) { .ai-input textarea { font-size: 14px; } }
.ai-send { width: 42px; height: 42px; flex-shrink: 0; border: 0; border-radius: 12px; display: grid; place-items: center; background: var(--grad-brand); color: #fff; cursor: pointer; box-shadow: 0 4px 12px rgba(4, 30, 80, .25); }
.ai-send svg { width: 20px; height: 20px; stroke-width: 2.4; }
.ai-send.is-stop { background: var(--c-slate-600); }
.ai-stop { width: 12px; height: 12px; border-radius: 3px; background: #fff; }
.ai-input__note { display: block; margin-top: 6px; font-size: 11.5px; color: var(--c-slate-400); text-align: center; }
.ai-input__note.is-fill { color: var(--c-accent-hover); font-weight: 600; }
.ai-input__note.is-warn { color: #B45309; animation: aiNudge .42s ease; }
@keyframes aiNudge { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.ai-code { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 8px 10px; border-radius: 10px; background: #FFF6E5; font-size: 13px; color: #92400E; }
.ai-code[hidden] { display: none; }
.ai-code span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; } .ai-code span svg { width: 15px; height: 15px; }
.ai-code input { flex: 1; min-width: 0; height: 32px; padding: 0 10px; border: 1px solid #F3D59B; border-radius: 8px; font: inherit; font-size: 16px; }

/* ---------- 寬螢幕：對話窗固定在右側，畫面讓出空間 ---------- */
@media (min-width: 1280px) {
  html.ai-docked .app { padding-right: calc(var(--ai-w) + var(--ai-gap) * 2); transition: padding-right .25s ease; }
  html.ai-docked .sheet__panel, html.ai-docked .sheet.has-marks .sheet__panel { right: calc(var(--ai-w) + var(--ai-gap) * 2); width: min(1120px, calc(100% - var(--ai-w) - var(--ai-gap) * 2 - 160px)); }
  html.ai-docked .sheet__backdrop { right: 0; }
  html.ai-docked .ai-panel { box-shadow: 0 18px 48px rgba(4, 30, 80, .22), 0 0 0 1px rgba(10, 44, 102, .08); }
}
@media (min-width: 1280px) and (max-width: 1699px) {
  html.ai-docked .ch-viz { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "trend trend" "alloc risk" "events events" "prod prod"; }
  html.ai-docked .vz-prod { flex-direction: row; align-items: center; } html.ai-docked .vz-prod__top { flex: 0 0 230px; } html.ai-docked .vz-pgrid { flex: 1; }
}

/* ---------- 情境按鈕 ---------- */
/* 客戶首頁：頁首「AI 助理」按鈕（以這位客戶開啟對話窗） */
.ai-custbtn { background: rgba(255, 255, 255, .1); color: #fff; border: 1px solid var(--c-gold); }
.ai-custbtn:hover { background: rgba(232, 184, 74, .18); }
.ai-custbtn svg { width: 16px; height: 16px; fill: var(--c-gold); stroke: none; }
/* 選單：客戶、商品（產品適配預檢、風險揭露提醒） */
.ai-pick { position: fixed; z-index: 58; display: flex; flex-direction: column; padding: 6px; border-radius: 14px; background: #fff;
  box-shadow: 0 18px 44px rgba(4, 30, 80, .28), 0 0 0 1px rgba(10, 44, 102, .08); animation: aiPickIn .16s ease both; }
.ai-pick__hd { padding: 6px 10px; font-size: 12px; font-weight: 700; color: var(--c-slate-500); }
.ai-pick__q { margin: 0 4px 6px; height: 34px; padding: 0 10px; border: 1px solid var(--c-border); border-radius: 9px; background: var(--c-bg-page); font: inherit; font-size: 13px; color: var(--c-ink); outline: none; }
.ai-pick__q:focus { border-color: var(--c-accent); background: #fff; box-shadow: 0 0 0 3px var(--c-accent-soft); }
.ai-pick [data-i][hidden] { display: none; }
.ai-pick__list { flex: 1; min-height: 0; overflow-y: auto; }
.ai-pick button { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 9px;
  background: none; font: inherit; text-align: left; color: var(--c-ink); cursor: pointer; }
.ai-pick button:hover, .ai-pick button:focus-visible { background: var(--c-accent-soft); outline: none; }
.ai-pick b { font-size: 13px; font-weight: 600; line-height: 1.3; }
.ai-pick small { flex-shrink: 0; font-size: 11.5px; color: var(--c-slate-500); white-space: nowrap; }
.ai-pick .ai-pick__other { justify-content: flex-start; gap: 6px; margin-top: 4px; border-top: 1px solid var(--c-border); border-radius: 0 0 9px 9px;
  color: var(--c-accent-hover); font-size: 13px; font-weight: 600; }
.ai-pick__other svg { width: 14px; height: 14px; flex-shrink: 0; }
@keyframes aiPickIn { from { opacity: 0; transform: translateY(-4px); } }

/* 客戶查詢：頁首按鈕 */
.ai-pagebtn { margin-left: auto; }
.ai-pagebtn svg { width: 16px; height: 16px; fill: var(--c-gold); stroke: none; }

/* ---------- 手機、平板 ---------- */
@media (max-width: 640px) {
  .ai-fab { right: 14px; bottom: calc(76px + env(safe-area-inset-bottom)); height: 48px; padding: 0 16px 0 13px; font-size: 14px; }
  .ai-panel { inset: 0; width: auto; border-radius: 0; }
  .ai-panel.is-open { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .ai-fab, .ai-fab::before, .ai-msg, .ai-hello, .ai-pick, .lang-menu, .ai-input__note.is-warn { animation: none; }
  .ai-panel { transition: opacity .15s ease; transform: none; }
}

/* 語系切換（i18n.js）：頁首右側與登入頁右上角 */
.lang-btn svg { width: 16px; height: 16px; }
.lang-btn span { font-weight: 700; letter-spacing: .02em; }
.login__panel { position: relative; }
.lang-btn--login { position: absolute; top: 16px; right: 16px; }
/* 語言選單（繁體中文／English／日本語） */
.lang-menu { position: fixed; z-index: 95; min-width: 152px; padding: 6px; border-radius: 12px; background: #fff;
  box-shadow: 0 18px 44px rgba(4, 30, 80, .28), 0 0 0 1px rgba(10, 44, 102, .08); animation: aiPickIn .16s ease both; }
.lang-menu button { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 36px; padding: 6px 10px; border: 0; border-radius: 8px;
  background: none; font: inherit; font-size: 13.5px; font-weight: 500; text-align: left; color: var(--c-ink); cursor: pointer; }
.lang-menu button:hover, .lang-menu button:focus-visible { background: var(--c-accent-soft); outline: none; }
.lang-menu button[aria-checked="true"] { color: var(--c-accent-hover); font-weight: 700; }
.lang-menu svg { width: 15px; height: 15px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 各語系共用的版面修正：手機寬度時月曆與資產配置圖例不超出卡片 ---------- */
.cal { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.vz-legend { grid-template-columns: minmax(0, 1fr); }
/* 頂列依實際寬度精簡（由 agent.js 依頂列寬度加上 is-w1／is-w2／is-w3；比照 style.css 在視窗 1280px、1100px 以下的作法） */
.topbar.is-w1 .user-btn__text small { display: none; }
.topbar.is-w2 { gap: 10px; padding: 0 16px; }
.topbar.is-w2 .crumb, .topbar.is-w2 .user-btn__text { display: none; }
.topbar.is-w2 .gsearch { flex: 1 1 240px; min-width: 0; }
.topbar.is-w2 .marquee { flex: 1 1 200px; min-width: 120px; }
.topbar.is-w3 .marquee { display: none; }
