html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #ffffff;
}

#chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 800px;
  margin: 0 auto;
  background-color: #ffffff;
}

h1 {
  text-align: center;
  padding: 20px;
  margin: 0;
  background-color: #ffffff;
  color: #333;
}

#messages {
  height: calc(100vh - 200px); /* Prevents scrollbar from being cut off */
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-sizing: border-box;
  padding-bottom: 10px; /* Increased to prevent scroll bar from being hidden behind form */
}

.message {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 16px;
  white-space: pre-wrap;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(10px);
  animation: fadeInUp 0.4s ease forwards;
  overflow-wrap: anywhere;
  word-break: break-word;
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: none;
  }
}

.user {
  background-color: #daf1ff;
  align-self: flex-end;
  text-align: left;
}

.assistant {
  background-color: #ffffff;
  align-self: flex-start;
  text-align: left;
  max-width: 90%;
  margin-left: 5%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

form {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 20px 16px; /* ← 40pxから16pxに変更（重要） */
  display: flex;
  gap: 10px;
  align-items: flex-end;  /* ★ ここを追加！下揃えにする */
  border-top: none;
  background-color: #ffffff;
}

textarea#user-input {
  flex-grow: 1;
  height: 68px;                         /* 高さを2行分に固定（line-height: 1.5 × 2行） */
  padding: 10px 12px 12px 12px; /* ← 下の余白20px → 12pxに変更 */
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 16px;
  font-family: inherit;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  resize: none;                        /* ユーザーのリサイズ無効 */
  overflow-y: auto;                    /* テキストが多いときに縦スクロール */
  line-height: 1.5;
  white-space: pre-wrap;              /* 折り返し有効 */
  word-break: break-word;
  box-sizing: border-box;             /* paddingも高さに含める */
  scrollbar-gutter: stable both-edges;  /* スクロールバーのスペース確保 */
}

button {
  height: 44px;              /* ★ 高さを固定 */
  padding: 0 20px;           /* ★ 上下の余白をゼロにして高さを固定しやすく */
  border: none;
  border-radius: 8px;
  background-color: #0066cc;
  color: white;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

button#reset {
  background-color: #888;
}

#loading-indicator {
  display: none;
  text-align: center;
  font-style: italic;
  color: #666;
  margin: 10px 0;
  animation: blink 1.5s infinite;
}

@keyframes blink {
  0% { opacity: 0.2; }
  50% { opacity: 1; }
  100% { opacity: 0.2; }
}

#scroll-button {
  position: fixed;
  bottom: 65px; /* フォームの上に浮く */
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background-color: rgba(0, 0, 0, 0.85); /* 半透明な黒 */
  color: white;
  padding: 6px 12px;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
  display: none;
  transition: opacity 0.3s, transform 0.3s;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

#scroll-button:hover {
  opacity: 1;
  transform: translateX(-50%) scale(1.05); /* 少し大きく */
}

#messages .disclaimer {
  color: #888;         /* 薄いグレー */
  font-size: 0.85em;   /* 少し小さく */
  font-style: italic;  /* 念のためイタリック指定 */
}