/* ==============================
   Chat Bubbles: drop-in stylesheet
   対象: <ul id="log-list"> 内の
        <li class="user"> / <li class="assistant">
   依存: なし（変数はデフォルト値付き）
   ============================== */

/* カラーテーマ（必要なら上書きしてください） */
:root {
  --cb-user-bg:    #e6f0ff;
  --cb-user-bd:    #b4d1ff;
  --cb-user-text:  #0f2e62;
  --cb-ai-bg:      #f4fbe9;
  --cb-ai-bd:      #cce8b8;
  --cb-ai-text:    #225522;
  --cb-accent:     #00695c;

  --cb-radius:     16px;
  --cb-gap-y:      10px;
  --cb-gap-x:      10px;
  --cb-maxw:       min(78ch, 92%);
  --cb-shadow:     0 4px 12px rgba(0,0,0,.06);
  --cb-font:       system-ui, -apple-system, "Noto Sans JP", sans-serif;
}

/* ログリストのベース */
#log-list {
  list-style: none;
  margin: 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: var(--cb-gap-y);
  font-family: var(--cb-font);
}

/* 各メッセージ共通 */
#log-list li {
  position: relative;
  max-width: var(--cb-maxw);
  padding: 10px 12px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap; /* 改行保持 */
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  border: 1px solid transparent;
}

/* user: 右寄せの吹き出し */
#log-list li.user {
  margin-left: auto;
  color: var(--cb-user-text);
  background: var(--cb-user-bg);
  border-color: var(--cb-user-bd);
  border-top-right-radius: 6px; /* 角に変化 */
}

/* assistant: 左寄せの吹き出し */
#log-list li.assistant {
  margin-right: auto;
  color: var(--cb-ai-text);
  background: var(--cb-ai-bg);
  border-color: var(--cb-ai-bd);
  border-top-left-radius: 6px; /* 角に変化 */
}

/* 吹き出しの“しっぽ” */
#log-list li.user::after,
#log-list li.assistant::after {
  content: "";
  position: absolute;
  bottom: -2px;
  width: 10px;
  height: 10px;
  transform: rotate(45deg);
  border: 1px solid currentColor; /* 枠の継承っぽく */
  border-color: inherit;
  background: inherit;
  z-index: 0;
}

#log-list li.user::after {
  right: -5px;
  border-left: none;
  border-top: none;
}

#log-list li.assistant::after {
  left: -5px;
  border-right: none;
  border-top: none;
}

/* 例文ボタンの塊（既存クラスに軽い余白と折返し） */
#log-list .ex-btn-wrap {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#log-list .ex-btn {
  font: inherit;
  line-height: 1.2;
  padding: 5px 9px;
  cursor: pointer;
  border: 1px solid color-mix(in oklab, var(--cb-accent), white 60%);
  background: white;
  color: var(--cb-accent);
  border-radius: 6px;
  max-width: 100%;
  white-space: normal; /* 改行許可 */
  text-align: left;
  transition: background .15s, color .15s, border-color .15s;
}
#log-list .ex-btn:hover:not(:disabled){
  background: color-mix(in oklab, var(--cb-accent), white 85%);
  border-color: var(--cb-accent);
}
#log-list .ex-btn:active:not(:disabled){
  background: color-mix(in oklab, var(--cb-accent), black 10%);
  color: white;
}
#log-list .ex-btn:focus-visible{
  outline: 2px solid color-mix(in oklab, var(--cb-accent), black 10%);
  outline-offset: 1px;
}
#log-list .ex-btn:disabled{
  opacity: .55;
  cursor: not-allowed;
  filter: grayscale(.3);
}

/* 波形ローダー（.wave-loader .bar を装飾） */
.wave-loader{
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  height: 18px;
}
.wave-loader .bar{
  width: 3px;
  height: 6px;
  background: color-mix(in oklab, var(--cb-accent), white 25%);
  border-radius: 2px;
  animation: cb-wave 1s ease-in-out infinite;
}
.wave-loader .bar:nth-child(2){ animation-delay: .1s }
.wave-loader .bar:nth-child(3){ animation-delay: .2s }
.wave-loader .bar:nth-child(4){ animation-delay: .3s }
.wave-loader .bar:nth-child(5){ animation-delay: .4s }
@keyframes cb-wave{
  0%,100%{ height: 6px; opacity:.7 }
  50%   { height: 18px; opacity:1 }
}
.loading-hint{
  font-size: .9rem;
  color: #666;
}

/* 入力エリアとPDF周りはそのままでもOK。念のため軽く整える */
#input-area{
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
#input-area input{
  flex: 1;
  padding: 8px 10px;
  font: inherit;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}
#input-area button{
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
  border: 1px solid color-mix(in oklab, var(--cb-accent), white 60%);
  background: white;
  color: var(--cb-accent);
  border-radius: 10px;
  transition: background .15s, color .15s, border-color .15s, transform .02s;
}
#input-area button:hover{ background: color-mix(in oklab, var(--cb-accent), white 85%) }
#input-area button:active{ transform: translateY(1px) }

/* PDFエリアの微調整（任意） */
.pdf-area{ text-align:center; margin-top: 10px }
.pdf-caption{ margin-top: 4px; font-size: .9rem; color:#555 }

/* 印刷時は影を消して節約 */
@media print {
  #log-list li { box-shadow: none }
}
