html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: auto;
  min-height: 100%;
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center center;
  background-attachment: fixed; /* ✅ 背景は固定 */
  background-color: white;
  font-family: 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  z-index: -1;
}



/* === 全体背景調整 === */
body {
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: fixed;  /* ✅ これが画像を固定するポイント！ */
  background-color:  white;
  margin: 0;
  padding: 0;
  font-family: 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
}

/* 共通：無料版だけチャットボックスを短く */
body.free-version .chat-window {
  height: 60vh !important; /* 好みで調整。例：60%の高さに制限 */
}


.header-title {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 16px;
}

.title-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  image-rendering: pixelated;
}

/* === スマホチャットボックス縮小 === */
.chat-window {
  width: 100%;
  height: calc(var(--vh, 1vh) * 80); /* ← JSで設定するvhを使う */
  max-width: 600px;         /* PCでは最大600pxに制限 */
  margin: 40px auto;        /* ← 中央寄せ */
  margin-bottom: 8px;  /* ← 必要最小限に */
  padding: 20px;
  background-color: rgba(192, 192, 192, 0.85);  /* ← 明るいグレー */
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  color: black;
}

.chat-box {
  height: 100%;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch; /* ← stretchのままでOK */
  overflow-y: auto;
}

.chat-bubble {
  display: flex;
  align-items: flex-start;
  margin: 4px 0;
}

.chat-bubble.user {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-start;
  align-items: flex-start;

  /* ✅ 右端に寄せる */
  align-self: flex-end;
  margin: 4px 0;

  /* ❌ 削除する：width: 100%; */
  /* ✅ 代わりに入れると安定する場合あり： */
  /* max-width: 100%; */
}

.chat-bubble.assistant {
  justify-content: flex-start;
}

.chat-bubble.assistant .bubble {
  background-color: white;
  color: black;
  max-width: 80%;
}

.icon {
  width: 36px;
  height: 36px;
  margin-right: 6px;
  border-radius: 50%;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.bubble {
  background-color: rgba(255, 255, 255, 0.9);
  padding: 8px 12px;
  border-radius: 12px;
  max-width: 95%;
  min-width: 7em;
  font-size: 16px;
  line-height: 1.4;
  white-space: normal;    /* ← 改行を許可（pre-wrap ではなく normal） */
  word-break: keep-all;   /* ← 英単語や短文が途中で折れないように */
  word-wrap: break-word;
  display: inline-block;
  box-sizing: border-box;
  overflow-wrap: break-word;   /* ← 長い単語だけ折り返す */
  text-align: left;       /* ← 左寄せ */
  justify-content: flex-start;  /* Flex方向での左寄せ */
}

.chat-bubble.user .bubble {
  background-color: #6cbb5a;
  color: white;
  text-align: left;
  max-width: 95%;
  word-break: break-word;
  white-space: normal;
}

.bubble p {
  margin: 0;
  padding: 0;
  word-break: normal;
}

.timestamp {
  display: none;
}

.chat-input {
  display: flex;
  margin-top: 10px;
  gap: 8px;
}

.chat-input input {
  flex-grow: 1;
  padding: 10px;
  font-size: 16px;
}

.chat-input button {
  padding: 10px 20px;
  background-color: #007bbb;
  color: #fff;
  font-weight: bold;
  border: none;
  cursor: pointer;
}

.info-button-container {
  text-align: center;
  margin-top: 20px;
}

.info-button {
  background-color: #2196f3;
  color: white;
  padding: 10px 20px;
  text-decoration: none;
  font-weight: bold;
  border-radius: 8px;
  display: inline-block;
  font-size: 16px;
}

.info-button:hover {
  background-color: #0b7dda;
}
/* === チャットウィンドウ全体を中央に配置 === */
.wrapper {
  max-width: 600px;
  margin: 0 auto;
  margin-bottom: 0;
  padding-bottom: 0;   /* ← 余分な余白があればここでカット */
  padding: 8px;
  box-sizing: border-box;
  text-align: center;
}

/* ボタン */
.readme-button {
  display: block;
  width: 100%;              /* ← wrapperに合わせる */
  max-width: 100%;          /* ← チャットボックスと同じに */
  margin-bottom: 8px;
  padding: 10px;
  background-color: #0F5474; /* 藍色 */
  color: #fff;
  font-weight: bold;
  font-size: 14px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
}


/* スマホ対応 */
@media (max-width: 600px) {
  body {
    background-position: center 110%;  /* 数字を増やすとより下側が表示される */
  }

  body.free-version .chat-window {
    height: 55vh !important;
  }

  .header-title h1 {
    font-size: 1.1em !important;
    line-height: 1.2;
  }
  .chat-window {
    max-width: 92vw;       /* ← スマホでは画面幅の92% */
    height: 80vh; /* ← ここでスマホ用に高さを調整 */
    margin: 20px auto;
    padding: 12px;
  }

  .readme-button,
  .reset-topic-btn,
  .reset-history-btn {
    font-size: 14px;
    padding: 10px;
    max-width: 100%;
  }

  .chat-box {
    max-height: 60vh;
    gap: 6px;
    overflow-y: auto;
  }

  .icon {
    width: 28px;
    height: 28px;
  }

  .bubble {
    width: fit-content;
    max-width: 95%;
    min-width: 40%;
    box-sizing: border-box;
    font-size: 16px;
    padding: 8px 12px;
  }

  .chat-input {
    flex-direction: column;
    gap: 8px;
    width: 100%; /* ✅ 追加推奨 */
  }
  .reset-topic-btn,
  .reset-history-btn,
  .chat-input button {
    width: 100%;
    box-sizing: border-box;
    font-size: 18px;
    padding: 14px;
  }

  .reset-topic-btn {
    font-size: 16px;
    padding: 12px;
    box-sizing: border-box; /* ✅ はみ出し防止 */
  }

  .footer-links {
    font-size: 1rem;
    line-height: 1.2;
    margin-top: 6px;
  }

  .content-box a {
    text-align: center;
    font-size: 0.8rem;
    white-space: nowrap;  /* ✅ 自動改行を防ぐ */
    display: inline-block;  /* ✅ ブロックにならないように */
    margin: 0 8px;
    text-decoration: underline;
    color: white;
  }

  .ad-slot {
    max-width: 320px;
    height: 60px;       /* モバイル広告に合わせて高さ調整 */
    overflow: hidden;
  }

  .pc-only {
    display: none;
  }
  .mobile-only {
    display: block;
  }
}

  .content-box .footer-links {
    font-size: 0.8rem; /* ← 適切なサイズに修正 */
    text-align: center;
    margin-top: 8px;
    color: white;
  }

  .content-box a {
    font-size: 10px !important;
    color: white; /* 任意の色 */
    text-decoration: underline; /* または none */
  }

  .chat-bubble .bubble {
    width: 90%;              /* ← 固定幅に */
    max-width: 90%;          /* 念のため */
    box-sizing: border-box;
    word-break: break-word;
    white-space: normal;
  }

  .chat-bubble.user .bubble {
    background-color: #00C300;
    color: white;
    text-align: left;
    max-width: 95%;
    word-break: break-word;
    white-space: normal;
  }

  .chat-bubble.assistant .bubble {
    width: fit-content;
    max-width: 90%;
    word-break: break-word;
    white-space: normal;
    overflow-wrap: break-word;
    font-size: 16px;
    padding: 8px 12px;
    box-sizing: border-box;
  }

/*  .footer-linksf {
    font-size: 1rem;
    text-align: center;
    margin-top: 8px;
    color: white;
  }

  .footer-linksf a {
  color: white;
  text-decoration: underline;
  margin: 0 4px;
  font-size: inherit;
  } */

  .reset-buttons {
    display: flex;
    flex-direction: row;        /* ← 横並びに明示 */
    gap: 8px;
    justify-content: space-between;
  }
  .reset-buttons form {
    flex: 1;                    /* ← ボタンの幅を均等に */
  }
  .reset-buttons button {
    width: 100%;                /* ← 各フォーム内で全幅にする */
    font-size: 14px;
    padding: 10px;
  }

  .content-box {
    max-width: 92vw;
    margin: 16px auto;
    padding: 16px;
    font-size: 1.1rem;
    border-radius: 12px;
  }

  .contact-box {
    max-width: 100%;
  }

  .contact-box input[type="text"],
  .contact-box input[type="email"],
  .contact-box textarea {
    width: 100%;
    font-size: 1.1rem;
    padding: 10px;
    box-sizing: border-box;
  }

  .contact-box button {
    width: 100%;
    padding: 14px;
    font-size: 1.1rem;
    background-color: #007bbb;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    margin-top: 10px;
  }

  .contact-box button:hover {
    background-color: #005f99;
  }

  .contact-box label {
    font-size: 1rem;
    margin-top: 8px;
    display: block;
  }

  .contact-box a {
    font-size: 0.9rem;
    display: block;
    margin-top: 10px;
    text-align: center;
  }



.reset-topic-btn {
  width: 100%;                 /* 入力欄と揃える */
  background-color: #f8b500;
  border: none;
  padding: 10px;
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  margin-top: 6px;
  font-size: 16px;
  border-radius: 4px;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.title-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  image-rendering: pixelated;
}

.header-title h1 {
  margin: 0;
  font-size: 1.5em;
}

/* 最初は非表示 */
.chat-bubble.assistant.fade-in {
  opacity: 0;
  transition: opacity 0.4s ease-in-out;
}

/* 表示切替 */
.chat-bubble.assistant.fade-in.visible {
  opacity: 1;
}

.fade-in {
  opacity: 0;
  transition: opacity 0.5s ease-in;
}

.fade-in.visible {
  opacity: 1;
}

.reset-history-btn {
  width: 100%;
  background-color: #b7282e; /* 茜色 */
  border: none;
  padding: 10px;
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  margin-top: 5px;
}
.bg-image {
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
  background-attachment: fixed;
}
/* style.css に追加例 */
/* 考え中インジケーター用アニメーション */
.thinking-dots {
  display: flex;
  gap: 6px;
  padding: 4px 8px;
  justify-content: flex-start;
  align-items: center;
}

.thinking-dots span {
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: #333;
  border-radius: 50%;
  animation: blink 1.2s infinite ease-in-out;
}

.thinking-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.thinking-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0%, 80%, 100% {
    opacity: 0;
    transform: scale(0.6);
  }
  40% {
    opacity: 1;
    transform: scale(1.2);
  }
}
.sub-message {
  font-size: 0.85em;
  color: #eeeeee;
  margin: 4px 0 0 0;
  text-align: left;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
}
.daily-message {
  background-color: rgba(44, 107, 106, 0.8);
  padding: 2px 6px;      /* ← 上下2px、左右6px に縮小 */
  margin: 4px 0 6px 0;   /* ← 上下マージンも詰める */
  border-radius: 6px;
  color: #fff;
  font-weight: bold;
  text-align: center;
  font-size: 1.2rem;     /* PC用サイズ */
  line-height: 1.3;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

@media screen and (max-width: 768px) {
  .daily-message {
    font-size: 0.95rem;
    padding: 2px 5px;
    margin: 4px 0 6px 0;
    line-height: 1.2;
  }

  .content-box {
    margin: 20px 10px;
    padding: 15px;
    font-size: 0.95rem;
  }

  .content-box a{
    font-size: 1rem;
  }

  .footer-links {
    font-size: 0.7rem;
    line-height: 1.2;
  }

  .content-box .footer-links {
    font-size: 2rem; /* ← まずこのあたりで小さくして試す */
    text-align: center;
    margin-top: 8px;
    color: white; /* or 適切な色 */
  }

  .content-box .footer-links a {
    color: white;
    text-decoration: underline;
    margin: 0 4px;
    font-size: inherit;
  }

  .chat-bubble.user .bubble {
    background-color: #00C300;
    color: white;
    text-align: left;
    max-width: 95%;
    word-break: break-word;
    white-space: normal;
  }

    .chat-bubble.assistant .bubble {
    max-width: 95%;
  }
}

/* === フッターリンク 共通スタイル === */
.footer-links {
  font-size: 0.8rem;
  text-align: center;
  margin-top: 8px;
  color: rgb(192, 192, 192);
}

.footer-links a {
  color: rgb(192, 192, 192);
  text-decoration: underline;
  margin: 0 4px;
  font-size: inherit;
}


/*.footer-linksf {
  font-size: 1rem; 
  text-align: center;
  margin-top: 8px;
  color: white; 
}

.footer-linksf a {
  color: white;
  text-decoration: underline;
  margin: 0 4px;
  font-size: inherit;
} */

.content-box {
  max-width: 700px;
  margin: 40px auto;
  padding: 20px;
  background-color: rgba(0, 0, 0, 0.6);  /* ← これが“黒い背景”の本体 */
  border-radius: 12px;
  color: #fff;
  line-height: 1.7;
  font-size: 1rem;
  text-align: left;

  /* 🔽 追加 */
  position: relative;
  z-index: 1;
  box-sizing: border-box;
}

.content-box a {
  color: white;
  text-decoration: underline; /* または none */
  font-size: 14px !important; /* ← まずこのあたりで小さくして試す */
  text-align: center;
  margin-top: 8px;
}

.content-box a:hover {
  color: #ccc; /* ホバー時の色変更もおすすめ */
}

  /* ✅ 以下を削除または指定しないことで伸びを防止 */
  /* display: inline-block; ← これは外す */
  /* height: 100vh; ← 絶対に入れない */

.chat-input button:hover {
  background-color: #19448e;
}

.reset-topic-btn:hover {
  background-color: #f39800;
}

.reset-history-btn:hover {
  background-color: #c9171e;
}

.readme-button:hover {
  background-color: #192f60;
}

/* === content-box内のリンクスタイル（明示的に指定したい場合） === */
.content-box .footer-links {
  font-size: inherit;
  text-align: center;
  margin-top: 8px;
}

.content-box .footer-links a {
  color: inherit;
  text-decoration: underline;
  margin: 0 4px;
  font-size: inherit;
}

.readme-bubble {
  width: 95%;
  max-width: 95%;
  box-sizing: border-box;
}

.bubble.readme-bubble {
  max-width: 95% !important;     /* PC向けに幅拡張 */
  width: 95% !important;         /* 明示的に指定 */
  white-space: normal !important;
  word-break: break-word !important;
  overflow-wrap: break-word;
  display: block !important;     /* inline-blockだと折り返しに弱い */
  box-sizing: border-box;
}

/* Safariの折り返し対策：read_me.html専用のバブル */
.chat-box .chat-bubble .bubble {
  display: block !important;               /* ブロック化で折り返しバグを回避 */
  width: 100% !important;                  /* 最大幅を確保 */
  max-width: 100% !important;
  box-sizing: border-box;
  white-space: normal !important;
  word-break: break-word !important;
  overflow-wrap: break-word;
  font-size: 1rem;
}

.reset-buttons {
  display: flex;
  gap: 8px;                /* ボタン間の隙間 */
  justify-content: space-between;
  margin-top: 10px;
}

.reset-buttons form {
  flex: 1;
}

.reset-buttons .reset-topic-btn,
.reset-buttons .reset-history-btn {
  width: 100%;
  font-size: 14px;
  padding: 10px;
  box-sizing: border-box;
}

.contact-box {
  max-width: 90vw;         /* チャットボックスと同じぐらい */
  margin: 40px auto;
  padding: 20px;
  background-color: rgba(0, 0, 0, 0.6);
  color: white;
  border-radius: 15px;
  box-shadow: 0 0 10px rgba(0,0,0,0.3);
}

.contact-box input[type="text"],
.contact-box input[type="email"],
.contact-box textarea {
  width: 100%;
  padding: 8px;
  border: none;
  border-radius: 4px;
  font-size: 1em;
  box-sizing: border-box;
}

.ad-container {
  width: 100%;
  text-align: center;
  margin: 0;           /* ← デフォルトの上下10pxをリセット */
  padding: 0;
}

.ad-slot {
  max-width: 350px;
  margin: 0 auto;
  line-height: 0;       /* ← 高さ分の隙間防止 */
}



/* 表示切替 */
.pc-only {
  display: block;
}
.mobile-only {
  display: none;
}

@media (min-width: 768px) {
  body.mac .ad-container {
    display: none !important;
  }
}
