/* ZEAMI FAQ Bot widget — scoped under #zfb-root. ブランド別の色は widget.js が
   ZFB_CONFIG.theme から CSS変数(--zfb-accent 等)を注入する（単一CSSで全ブランド対応）。
   既定値は Art（アンバー）。 */
#zfb-root, #zfb-root * { box-sizing: border-box; }
#zfb-root {
  --zfb-primary: #1f2933;
  --zfb-accent: #fbb03b;
  --zfb-accent2: #f59e0b;
  --zfb-headtext: #3a2a06;
  --zfb-bot-bg: #f3f4f6;
  --zfb-user-bg: #fde8c4;
  --zfb-text: #20262e;
  --zfb-muted: #6b7280;
  --zfb-border: #e5e7eb;
  --zfb-link: #b45309;
  --zfb-pulse: rgba(251,176,59,.5);
  --zfb-focus: rgba(251,176,59,.25);
  /* Anchored to the VISUAL viewport via JS so it stays on-screen even on
     non-responsive / fixed-width pages. pointer-events:none lets the page
     stay clickable; children re-enable pointer-events. */
  position: fixed; left: 0; top: 0; width: 100vw; height: 100vh;
  pointer-events: none; transform-origin: top left;
  z-index: 2147483000;
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- corner (launcher + nudge) ---------- */
#zfb-corner {
  position: absolute; right: 20px; bottom: 20px; pointer-events: none;
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
}
#zfb-corner.zfb-hide { display: none; }

/* nudge speech bubble — gently invites the visitor to ask */
#zfb-nudge {
  position: relative; pointer-events: auto; max-width: 244px;
  background: #fff; color: var(--zfb-text);
  border-radius: 14px; border-left: 4px solid var(--zfb-accent);
  box-shadow: 0 10px 28px rgba(0,0,0,.18);
  padding: 11px 30px 11px 13px; font-size: 13px; font-weight: 600; line-height: 1.5;
  cursor: pointer; animation: zfb-nudgein .45s .1s both;
}
#zfb-nudge:after { content: ""; position: absolute; right: 26px; bottom: -7px; width: 14px; height: 14px;
  background: #fff; transform: rotate(45deg); box-shadow: 3px 3px 6px rgba(0,0,0,.05); }
#zfb-nudge .zfb-nx { position: absolute; top: 5px; right: 8px; color: #b9c0c8; font-size: 15px; line-height: 1;
  cursor: pointer; padding: 2px; }
#zfb-nudge .zfb-nx:hover { color: #6b7280; }
#zfb-nudge.zfb-hide { display: none; }
@keyframes zfb-nudgein { from { opacity: 0; transform: translateY(10px) scale(.96); } to { opacity: 1; transform: none; } }

/* launcher */
#zfb-launcher {
  position: relative; pointer-events: auto;
  display: inline-flex; align-items: center; gap: 9px;
  padding: 13px 20px 13px 16px;
  background: linear-gradient(135deg, var(--zfb-accent), var(--zfb-accent2)); color: var(--zfb-headtext);
  border: none; border-radius: 999px;
  box-shadow: 0 8px 22px rgba(0,0,0,.22);
  cursor: pointer; font-size: 15px; font-weight: 800; line-height: 1;
  transition: transform .15s ease, box-shadow .15s ease;
}
#zfb-launcher:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(0,0,0,.28); }
#zfb-launcher:before { content: ""; position: absolute; inset: 0; border-radius: 999px;
  box-shadow: 0 0 0 0 var(--zfb-pulse); animation: zfb-pulse 2.6s infinite; }
@keyframes zfb-pulse { 0% { box-shadow: 0 0 0 0 var(--zfb-pulse); } 70% { box-shadow: 0 0 0 15px rgba(0,0,0,0); } 100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); } }
#zfb-launcher .zfb-ic { display: inline-flex; align-items: center; justify-content: center; }
#zfb-launcher .zfb-on { position: absolute; top: 9px; left: 12px; width: 9px; height: 9px; border-radius: 50%;
  background: #22c55e; border: 2px solid #fff; }
#zfb-launcher.zfb-hide { display: none; }

/* panel — サイズは #zfb-root(JSで実表示領域=visualViewportに一致) の % 基準。
   100vh/100vw を使うと iOS でツールバー分はみ出してヘッダーが切れるため使わない。 */
#zfb-panel {
  position: absolute; right: 20px; bottom: 20px; pointer-events: auto;
  width: min(384px, calc(100% - 32px));
  height: min(580px, calc(100% - 32px));
  max-height: calc(100% - 16px);
  background: #fff; border-radius: 18px; overflow: hidden;
  box-shadow: 0 20px 54px rgba(0,0,0,.30);
  display: none; flex-direction: column;
  border: 1px solid var(--zfb-border);
}
#zfb-panel.zfb-open { display: flex; animation: zfb-pop .18s ease; }
@keyframes zfb-pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

#zfb-head {
  background: linear-gradient(135deg, var(--zfb-accent), var(--zfb-accent2)); color: var(--zfb-headtext);
  padding: 14px 16px; display: flex; align-items: center; gap: 11px;
}
#zfb-head .zfb-avatar { width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.92);
  color: var(--zfb-accent2); display:flex; align-items:center; justify-content:center; font-weight: 900; font-size: 18px;
  box-shadow: 0 2px 6px rgba(0,0,0,.12); }
#zfb-head .zfb-ttl { font-size: 15px; font-weight: 900; line-height: 1.2; }
#zfb-head .zfb-sub { font-size: 11.5px; opacity: .92; margin-top: 3px; display: flex; align-items: center; gap: 5px; }
#zfb-head .zfb-sub .zfb-gd { width: 7px; height: 7px; border-radius: 50%; background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34,197,94,.25); display: inline-block; }
#zfb-head .zfb-close { margin-left: auto; background: transparent; border: none; color: var(--zfb-headtext);
  font-size: 22px; line-height: 1; cursor: pointer; opacity: .85; padding: 4px; }
#zfb-head .zfb-close:hover { opacity: 1; }

#zfb-log { flex: 1; overflow-y: auto; padding: 16px; background: #fafafa; }
.zfb-row { display: flex; margin-bottom: 12px; }
.zfb-row.zfb-bot { justify-content: flex-start; }
.zfb-row.zfb-user { justify-content: flex-end; }
.zfb-bubble {
  max-width: 86%; padding: 10px 13px; border-radius: 14px; font-size: 14px; line-height: 1.65;
  color: var(--zfb-text); word-wrap: break-word; overflow-wrap: anywhere;
}
.zfb-bot .zfb-bubble { background: var(--zfb-bot-bg); border-top-left-radius: 4px; }
.zfb-user .zfb-bubble { background: var(--zfb-user-bg); border-top-right-radius: 4px; }
.zfb-bubble a { color: var(--zfb-link); text-decoration: underline; }
.zfb-bubble img { max-width: 100%; height: auto; border-radius: 6px; margin: 4px 0; }
.zfb-ans-title { font-weight: 800; display: block; margin-bottom: 6px; color: var(--zfb-primary); }
.zfb-text { white-space: normal; }
.zfb-more { margin-top: 9px; display: flex; flex-direction: column; gap: 3px; }
.zfb-src { font-size: 11.5px; color: var(--zfb-muted); }
.zfb-link { align-self: flex-start; font-size: 13px; font-weight: 700; color: var(--zfb-link); text-decoration: none;
  border: 1px solid var(--zfb-accent); border-radius: 8px; padding: 5px 11px; background: #fffdf7; }
.zfb-link:hover { filter: brightness(.97); }

/* chips */
.zfb-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.zfb-chip {
  background: #fff; border: 1px solid var(--zfb-accent); color: var(--zfb-primary);
  border-radius: 999px; padding: 7px 13px; font-size: 13px; cursor: pointer; line-height: 1.3;
  text-align: left; font-weight: 600; transition: background .12s ease, transform .12s ease;
}
.zfb-chip:hover { background: #fff7e9; transform: translateY(-1px); }
.zfb-chips.zfb-suggest { margin-top: 10px; }

/* related / escalation */
.zfb-related { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--zfb-border); }
.zfb-related .zfb-lbl { font-size: 12px; color: var(--zfb-muted); margin-bottom: 6px; }
.zfb-esc { margin-top: 10px; font-size: 12.5px; color: var(--zfb-muted); }
.zfb-esc a { color: var(--zfb-link); font-weight: 700; }

/* typing */
.zfb-typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.zfb-typing i { width: 7px; height: 7px; border-radius: 50%; background: #b8bec7; display: inline-block;
  animation: zfb-blink 1.2s infinite both; }
.zfb-typing i:nth-child(2) { animation-delay: .2s; }
.zfb-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes zfb-blink { 0%,80%,100% { opacity:.25; } 40% { opacity:1; } }

/* input */
#zfb-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--zfb-border); background: #fff; }
#zfb-input textarea {
  flex: 1; resize: none; border: 1px solid var(--zfb-border); border-radius: 10px;
  padding: 9px 11px; font-family: inherit; max-height: 96px; line-height: 1.4; color: var(--zfb-text);
  /* iOSはinputのfont-sizeが16px未満だとフォーカス時に自動ズーム→表示崩れ。16pxで抑止 */
  font-size: 16px;
}
#zfb-input textarea:focus { outline: none; border-color: var(--zfb-accent); box-shadow: 0 0 0 2px var(--zfb-focus); }
#zfb-send { background: linear-gradient(135deg, var(--zfb-accent), var(--zfb-accent2)); color: var(--zfb-headtext);
  border: none; border-radius: 10px; width: 44px; flex: 0 0 44px; cursor: pointer; font-size: 18px; font-weight: 800; }
#zfb-send:disabled { opacity: .5; cursor: default; }

#zfb-foot { font-size: 10.5px; color: var(--zfb-muted); text-align: center; padding: 6px 10px 9px; background:#fff; }

@media (max-width: 480px) {
  /* 実表示領域(#zfb-root)を上下左右8pxの余白で満たす。100vh不使用＝ヘッダーが切れない */
  #zfb-panel { top: 8px; right: 8px; bottom: 8px; left: 8px; width: auto; height: auto; max-height: none; border-radius: 14px; }
  #zfb-corner { right: 14px; bottom: 14px; }
  #zfb-nudge { max-width: 210px; }
}
