#chat-container {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s ease, transform 0.8s ease;
  /* 初期状態では非表示にする */
  display: none; /* これが最終的な初期display値になるように調整 */

  position: fixed;
  bottom: 30px;
  right: 20px;
  height: 70vh;
  width: 32vw;
  background: #eeeeee;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  flex-direction: column; /* flex-direction は保持 */
  font-family: sans-serif;
  z-index: 9999;
}

#chat-container.show {
  opacity: 1;
  transform: translateY(0);
  /* showクラスが付与されたらflex表示にする */
  display: flex;
}

/* .quick-link の見た目調整 */
#quick-questions {
  margin: 5px 0;
}

.faq-link {
  width: 100%;
  background: #fff;
  color: #2d8bd0;
  text-align: center;
  padding: 0.3rem;
  border-radius: 5px;
  margin-bottom: 5px;
  font-weight: 700;
  font-size: 0.8rem;
  border: solid 1px #2d8bd0;
}

#chat-launcher {
  position: fixed;
  bottom: 20px;
  right: 20px;
  color: white;
  padding: 0;
  border-radius: 24px;
  cursor: pointer;
  font-weight: bold;
  z-index: 9999;
  font-family: sans-serif;
  max-width: 150px;
}

.btn-kyuujin {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  margin-bottom: 10px; /* ランチャー内のボタンの余白 */
  border: none;
  padding: 0;
  background: none;
}

.btn-kanjya {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  padding: 0;
  border: none;
  background: none;
}

#chat-header {
  background: #007acc;
  color: white;
  padding: 10px 14px;
  font-weight: bold;
  position: relative;
  display: flex; /* ヘッダー内の要素をflexで配置 */
  align-items: center; /* 垂直方向中央揃え */
  justify-content: space-between; /* 要素を左右に配置 */
}

/* ヘッダー内のボタンの基本スタイル */
#chat-header button {
  background: none;
  border: none;
  color: white;
  font-size: 14px; /* 通常のボタンのフォントサイズ */
  cursor: pointer;
  margin-left: 8px; /* 各ボタン間にスペース */
  padding: 4px 8px;
  border-radius: 4px;
}

/* ヘッダー内のクローズボタン */
#chat-header #close-btn {
  font-size: 18px; /* クローズボタンは少し大きく */
  margin-left: auto; /* 右端に寄せる */
}

#chat-container.recruit-mode {
  background-color: #f9f4f5;
}

#chat-container.recruit-mode #chat-header {
  background: #e6709c;
}

#chat-container.recruit-mode input,
#chat-container.recruit-mode textarea {
  background-color: #f9f4f5;
  border-color: #e6709c;
}

/* #chat-close は #close-btn に変更されたので、このセレクタは削除済み */

#chat-messages {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.from-user {
  flex-direction: row-reverse;
}

.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.4;
  position: relative; /* 子要素のabsolute配置のために必要 */
}

.chat-link-btn{
	color: #0d6efd;
}
.user-bubble {
  background: #cce5ff;
  box-shadow: 2px 2px 10px 4px rgba(0, 0, 0, 0.05);
  border-radius: 16px 16px 0px;
}

.bot-bubble {
  background: white;
  box-shadow: 2px 2px 10px 4px rgba(0, 0, 0, 0.05);
  border-radius: 16px 16px 16px 0;
}

.chat-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #fff;
}

#chat-input {
  /* 初期状態では非表示にする */
  display: none; /* これが最終的な初期display値になるように調整 */
  padding: 10px;
  background: white;
  border-top: 1px solid #ccc;
  flex-direction: row; /* flex-direction は保持 */
}

#chat-input input {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #ccc;
}

#chat-input button {
  margin-left: 6px;
  padding: 8px 14px;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.faq-links {
  color: #0d6efd;
  text-decoration: underline;
}

.feedback-row {
  margin-left: 56px;
}

.chat-btn-red {
  margin: 4px 4px 0 0;
  padding: 4px;
  width: 60px;
  color: #fff;
  background: rgb(255, 102, 116);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  border: none;
}

.chat-btn-green {
  margin: 4px 4px 0 0;
  padding: 4px;
  width: 60px;
  color: #fff;
  background: rgb(76, 175, 80);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  border: none;
}

.feedback-btn:hover {
  background-color: #d0e9ff;
}

.fade-in {
  animation: fadeInUp 0.5s ease forwards;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.faq-example-btn {
  color: rgb(13, 110, 253);
  text-decoration: underline;
  text-align: left;
  background: none;
  border: none;
}

.example-block small {
  font-size: 0.6rem;
}

#chat-footer{text-align: center; margin: 0 auto; padding: 10px;}
#set-patient-button-in-chat, #set-recruit-button-in-chat{font-size: 12px; border:solid 1px #dedede; background: #fff;}

/* chat-link-btn のスタイル（既存） */
.chat-link-btn {
    display: inline-block;
    padding: 8px 15px;
    background-color: #1ca987;
    color: white;
    text-decoration: none;
    margin: 8px auto;
    border-radius: 5px;
    font-size: 0.9em;
    cursor: pointer;
    transition: background-color 0.3s ease;
}
.chat-link-btn:hover {
    background-color: #0f8468;
    color: white;
}

/* recruit-contactフローのボタンのスタイル */
.chat-row.feedback-row .chat-bubble button {
    /* 既存のチャットボタンのスタイルを上書きまたは追加 */
    margin-top: 10px; /* ボタン同士の間隔 */
    width: 100%; /* 全幅にするなど調整 */
    box-sizing: border-box; /* パディングやボーダーを含めて幅を計算 */
}

/* 画像が埋め込まれるメッセージのスタイル */
.chat-bubble img {
    max-width: 100%; /* 親要素に収まるように */
    height: auto; /* アスペクト比を維持 */
    display: block; /* 画像の下の余白をなくす */
    margin: 10px 0; /* 上下のマージン */
    border-radius: 5px; /* 角を丸くする */
}


/* ----------------------------------------------- */
/* ★★★ ここからが「入力中...」のアニメーションに関する修正です ★★★ */
/* ----------------------------------------------- */

/* 不要なセレクタとアニメーションを削除 */
/*
.chat-row.api-typing-indicator-row .chat-bubble.api-typing-indicator-bubble {
  font-style: italic;
  opacity: 0.7;
  position: relative;
  overflow: hidden;
  min-width: 60px;
  white-space: nowrap;
}

.chat-row.api-typing-indicator-row .chat-bubble.api-typing-indicator-bubble::after {
  content: '';
  position: absolute;
  right: 10px;
  bottom: 8px;
  font-weight: bold;
  animation: typingDots 1.5s infinite steps(1, end);
}

@keyframes typingDots {
  0% { content: '.'; }
  33% { content: '..'; }
  66% { content: '...'; }
  100% { content: '.'; }
}
*/

/* 新しいローディングメッセージ用のスタイル (これを使用します) */
.chat-bubble.typing-loader-bubble { /* .chat-rowは不要で、バブル自体に直接適用 */
    background-color: #e0e0e0; /* ローダー用の背景色 */
    color: #e0e0e0; /* ローダー用の文字色 */
    border-radius: 20px; /* 角丸はそのまま */
    padding: 8px 15px;
    font-size: 14px;
    max-width: 70%;
    word-wrap: break-word;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
    display: inline-flex; /* ドットを横並びにする */
    align-items: center;
    justify-content: center;
    /* 必要に応じて、ロード中のバブルの最小幅を設定 */
    min-width: 50px; 
}

/* タイピングインジケーターのCSS (ドットアニメーション) */
.typing-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #666;
    border-radius: 50%;
    animation: bounce 1s infinite ease-in-out;
    margin: 0 2px;
    opacity: 0.7;
}
/* 各ドットのアニメーション開始タイミングをずらす */
.chat-bubble .typing-indicator:nth-child(1) { animation-delay: 0s; }
.chat-bubble .typing-indicator:nth-child(2) { animation-delay: 0.15s; }
.chat-bubble .typing-indicator:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-5px); }
}



/* ----------------------------------------------- */
/* ★★★ CSS修正ここまで ★★★ */
/* ----------------------------------------------- */

@media screen and (max-width: 480px) {
  #chat-container {
    bottom: 0px;
    right: 0px;
    width: 100vw;
    height: 100dvh;
  }

  #chat-launcher {
    max-width: 120px;
  }
}