/* あんこ問い合わせAI フロント表示 */
#anko-chat-root {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", sans-serif;
  color: #2b2b2b;
}

/* 開閉ボタン */
/* v1.0.2〜v1.0.4: 下部固定メニュー（#fix_bottom_menu）と重ならないよう、bottom は
   CSS変数 --anko-fbm-offset（JSが実高さを測って設定）を使う。未設定時は16px。
   v1.0.4 ではJSがこのボタンへ直接 style.bottom も設定するため、CSS変数が
   効かない環境でも回避が効く（二重化）。 */
#anko-chat-toggle {
  position: fixed;
  right: 16px;
  bottom: var(--anko-fbm-offset, 16px);
  z-index: 99990;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 8px 10px;
  border: none;
  border-radius: 999px;
  background: #2e7d5b;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
#anko-chat-toggle img {
  /* v1.0.11: 顔がよく見えるよう拡大し、丸く切り抜いて顔中心に表示 */
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 44% 26%;
  background: #fff;
}
#anko-chat-toggle:hover {
  background: #276e50;
}

/* チャットウィンドウ */
#anko-chat-window {
  position: fixed;
  right: 16px;
  bottom: calc(var(--anko-fbm-offset, 16px) + 60px);
  z-index: 99991;
  display: flex;
  flex-direction: column;
  width: 360px;
  max-width: calc(100vw - 24px);
  height: 520px;
  max-height: calc(100vh - var(--anko-fbm-offset, 16px) - 84px);
  max-height: calc(100dvh - var(--anko-fbm-offset, 16px) - 84px);
  background: #fff;
  border: 1px solid #d8e2dc;
  border-radius: 14px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}
#anko-chat-window[hidden] {
  display: none;
}

.anko-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #eef6f1;
  border-bottom: 1px solid #d8e2dc;
}
.anko-chat-header-img {
  /* v1.0.11: 52px → 64px に拡大 */
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 44% 26%;
  background: #fff;
  flex: none;
}
.anko-chat-header-text {
  flex: 1;
  min-width: 0;
}
.anko-chat-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}
.anko-chat-subtitle {
  margin: 2px 0 0;
  font-size: 11px;
  color: #55705f;
}
#anko-chat-close {
  flex: none;
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: #55705f;
  padding: 4px 6px;
}

.anko-chat-notice {
  margin: 0;
  padding: 8px 12px;
  font-size: 11px;
  line-height: 1.5;
  background: #fff8e6;
  border-bottom: 1px solid #f0e3b8;
  color: #6b5510;
}

.anko-chat-messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain; /* v1.0.4: スクロールの連鎖で背景ページが動くのを防ぐ */
  padding: 12px;
  background: #fbfcfb;
}

.anko-chat-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}
.anko-chat-row-user {
  flex-direction: row-reverse;
}
.anko-chat-avatar {
  /* v1.0.11: 30px の contain 表示では横長画像が縮小され顔が見えにくかったため、
     44px に拡大し、丸く切り抜いて顔中心（ヘッダー画像と同じ位置）で表示する */
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 44% 26%;
  background: #fff;
  border: 1px solid #d8e2dc;
  flex: none;
}
.anko-chat-bubble {
  max-width: 74%;
  padding: 8px 11px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.anko-chat-row-assistant .anko-chat-bubble {
  background: #eef6f1;
  border: 1px solid #d8e2dc;
  border-top-left-radius: 4px;
}
.anko-chat-row-user .anko-chat-bubble {
  background: #2e7d5b;
  color: #fff;
  border-top-right-radius: 4px;
}
.anko-chat-bubble-typing {
  color: #55705f;
  font-style: italic;
}

.anko-chat-privacy {
  margin: 0;
  padding: 6px 12px 0;
  font-size: 10px;
  color: #8a8a8a;
}

.anko-chat-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid #e3eae6;
  background: #fff;
}
#anko-chat-input {
  flex: 1;
  resize: none;
  border: 1px solid #c9d6cd;
  border-radius: 8px;
  padding: 8px;
  font-size: 13px;
  font-family: inherit;
}
#anko-chat-send {
  flex: none;
  border: none;
  border-radius: 8px;
  background: #2e7d5b;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 0 14px;
  cursor: pointer;
}
#anko-chat-send:disabled {
  background: #9db8a9;
  cursor: default;
}

.anko-chat-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* v1.0.4: スマホ表示（幅999px以下）の調整。従来の max-width:480px の指定を
   999px 以下全体へ広げ、次の2点を追加した。
   追加修正B: ウィンドウを右寄せ固定幅にせず、left:12px / right:12px /
   width:auto の左右マージン方式にして、画面幅に必ず収まるようにする
   （iOS Safari の自動ズーム時などでも右端がはみ出さない）。
   visualViewport 同期中はJSが top / height のみを上書きし、横方向は
   この指定がそのまま効く（追加修正D）。
   追加修正A: 入力欄のフォントサイズを16pxにし、iPhone Safari が
   フォーカス時に自動ズームするのを防ぐ（16px未満だとズームして
   固定配置の要素がはみ出すため）。
   v1.0.5: カスタマイザーのスマホ表示（幅400px）での実測で、下部固定
   メニューバーは高さ34px・上端が画面下端から41pxの位置にあり、動的
   計測が効かない場合にボタンが26px重なることが分かった。そのため
   このブレークポイントでは --anko-fbm-offset の既定値を 64px に固定し
   （バーの上端41pxに対して23pxの余裕）、JSの計測が効いた場合も
   64px を下限とする。旧 max-width:480px ブロックは v1.0.4 でこの
   ブロックへ統合済みのため、既定値の統一もここで行う。 */
@media (max-width: 999px) {
  #anko-chat-window {
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
    bottom: calc(var(--anko-fbm-offset, 64px) + 60px);
    height: calc(100vh - var(--anko-fbm-offset, 64px) - 84px);
    height: calc(100dvh - var(--anko-fbm-offset, 64px) - 84px);
    max-height: calc(100vh - var(--anko-fbm-offset, 64px) - 84px);
    max-height: calc(100dvh - var(--anko-fbm-offset, 64px) - 84px);
  }
  #anko-chat-toggle {
    right: 12px;
    bottom: var(--anko-fbm-offset, 64px);
  }
  #anko-chat-input {
    font-size: 16px;
  }
}

/* v1.0.11: タブレット表示（幅600〜999px）は、スマホのような全幅表示ではなく
   PCと同じ「画面の一部（右下の固定幅ウィンドウ）」にする。
   上の max-width:999px ブロックより後に置き、該当プロパティだけを上書きする。
   下部固定メニューとの重なり回避（bottom の64px既定値）はそのまま使う。
   キーボード表示時の visualViewport 同期と背景スクロール固定は JS 側で
   幅599px以下（スマホ）だけに限定し、タブレットではPCと同じ挙動にする。 */
@media (min-width: 600px) and (max-width: 999px) {
  #anko-chat-window {
    left: auto;
    right: 16px;
    width: 380px;
    max-width: calc(100vw - 32px);
    bottom: calc(var(--anko-fbm-offset, 64px) + 60px);
    height: 520px;
    max-height: calc(100vh - var(--anko-fbm-offset, 64px) - 84px);
    max-height: calc(100dvh - var(--anko-fbm-offset, 64px) - 84px);
  }
  #anko-chat-toggle {
    right: 16px;
  }
}
