@charset "UTF-8";
/* =========================================================================
   chat.css — 診断チャットのLINE風レイアウト
   構造はLINE準拠、配色はサイトのパレット。
   チャット領域内にオレンジは使わない（フォーカス表示のみ例外）。
   style.css の後に読み込むこと。
   ========================================================================= */

.diagnosis-page {
  --chat-bg: #edf1f5;
  --chat-self: #8de055;
  --chat-text: #333333;
  --chat-meta: #7a8794;
  --chat-line: #dfe5eb;
  --chat-radius: 18px;
  --chat-tight: 5px;
}

/* ---------- 自動応答の告知（吹き出しではない） ---------- */
.chat-system-note {
  margin: 0 0 14px;
  padding: 8px 14px;
  color: var(--chat-meta);
  font-size: 13px;
  line-height: 1.7;
  text-align: center;
}

/* ---------- チャット領域 ---------- */
.diagnosis-page .chat-log {
  display: grid;
  gap: 12px;
  padding: 16px 12px 20px;
  background: var(--chat-bg);
  border-radius: 14px;
}

.diagnosis-page .chat-message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
}

.diagnosis-page .chat-message--user { justify-content: flex-end; }

.diagnosis-page .chat-avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  align-self: flex-start;
  margin-top: 20px;          /* 話者名のぶん下げて吹き出しと肩を揃える */
  object-fit: cover;
  object-position: 50% 22%;
  background: #dbe6ee;
  border: none;
  border-radius: 50%;
  box-shadow: none;
}

.diagnosis-page .chat-message__body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 80%;
}

.diagnosis-page .chat-speaker {
  margin: 0 0 4px 2px;
  color: var(--chat-meta);
  font-size: 12px;
  line-height: 1.4;
  font-weight: 600;
}

/* 連続する同一話者はアバターと名前を省略して詰める */
.diagnosis-page .chat-message.is-continued { margin-top: -6px; }
.diagnosis-page .chat-message.is-continued .chat-avatar { visibility: hidden; margin-top: 0; }
.diagnosis-page .chat-message.is-continued .chat-speaker { display: none; }

/* ---------- 吹き出し ---------- */
.diagnosis-page .chat-bubble {
  position: relative;
  padding: 11px 14px;
  color: var(--chat-text);
  background: #ffffff;
  border: 1px solid var(--chat-line);
  border-radius: var(--chat-tight) var(--chat-radius) var(--chat-radius) var(--chat-radius);
  box-shadow: none;
  font-size: 16px;
  line-height: 1.75;
  overflow-wrap: anywhere;
  max-width: 100%;
}

/* 旧スタイルの吹き出しツメを無効化 */
.diagnosis-page .chat-message--operator .chat-bubble::before { content: none; }

.diagnosis-page .chat-message--user .chat-bubble {
  max-width: 80%;
  color: var(--chat-text);
  background: var(--chat-self);
  border-color: var(--chat-self);
  border-radius: var(--chat-radius) var(--chat-tight) var(--chat-radius) var(--chat-radius);
  box-shadow: none;
}

/* ---------- 既読・時刻 ---------- */
.diagnosis-page .chat-meta {
  display: flex;
  flex-direction: column;
  flex: none;
  gap: 1px;
  padding-bottom: 2px;
  color: var(--chat-meta);
  font-size: 11px;
  line-height: 1.3;
  white-space: nowrap;
}

.diagnosis-page .chat-message--user .chat-meta {
  align-items: flex-end;
  order: -1;                 /* 吹き出しの左下に置く（LINEと同じ配置） */
}

.diagnosis-page .chat-message--operator .chat-meta { align-items: flex-start; }

.diagnosis-page .chat-read { font-size: 11px; }

/* ---------- タイピングインジケータ ---------- */
.diagnosis-page .chat-bubble--typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 14px 16px;
  width: fit-content;
}

.diagnosis-page .chat-bubble--typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b2bec9;
  animation: chat-typing 1.1s infinite ease-in-out;
}

.diagnosis-page .chat-bubble--typing span:nth-child(2) { animation-delay: .18s; }
.diagnosis-page .chat-bubble--typing span:nth-child(3) { animation-delay: .36s; }

@keyframes chat-typing {
  0%, 60%, 100% { opacity: .35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ---------- 選択肢の登場 ----------
   質問の吹き出しが出たあと、少し間を置いてまとめて1回で出す。
   回答パネルはチャットログの下にあるため、伸びるのは下方向のみ。 */
.diagnosis-page .chat-answer-content.is-revealing {
  animation: composer-in 200ms ease-out both;
}

@keyframes composer-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- 選択肢ボタン ---------- */
.diagnosis-page .chat-choice-grid,
.diagnosis-page .choice-grid {
  display: grid;
  grid-template-columns: 1fr;   /* 横に並べきれない場合は縦積み。横スクロールは作らない */
  gap: 10px;
}

.diagnosis-page .choice-button {
  position: relative;
  width: 100%;
  min-height: 48px;
  padding: 12px 44px 12px 16px;
  color: #13457B;
  background: #ffffff;
  border: 1.5px solid #13457B;
  border-radius: 10px;
  font-size: 16px;
  line-height: 1.6;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, opacity 140ms ease;
  touch-action: manipulation;
}

.diagnosis-page .choice-button::after {
  position: absolute;
  top: 50%;
  right: 16px;
  width: 8px;
  height: 8px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  content: "";
  transform: translateY(-50%) rotate(45deg);
  opacity: .8;
}

.diagnosis-page .choice-button:hover,
.diagnosis-page .choice-button:active {
  background: #dce9f5;
  transform: none;
}

.diagnosis-page .choice-button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* 選択後：選んだものを紺の塗り、他は薄く落とす */
.diagnosis-page .choice-button[aria-pressed="true"] {
  color: #ffffff;
  background: #13457B;
  border-color: #13457B;
}

.diagnosis-page .choice-grid:has(.choice-button[aria-pressed="true"]) .choice-button[aria-pressed="false"] {
  opacity: .45;
}

/* ---------- チャット内の他要素 ---------- */
.diagnosis-page .chat-privacy-note { font-size: 13px; line-height: 1.7; }
.diagnosis-page .answer-step-label { font-size: 13px; }

@media (min-width: 700px) {
  .diagnosis-page .chat-log { padding: 20px 18px 24px; }
  .diagnosis-page .chat-message__body { max-width: 72%; }
}

/* ---------- 動きを減らす設定 ---------- */
@media (prefers-reduced-motion: reduce) {
  .diagnosis-page .chat-bubble--typing span { animation: none; opacity: .6; }
  .diagnosis-page .chat-message.is-new { animation: none; }
  .diagnosis-page .chat-answer-content.is-revealing { animation: none; }
}

/* ---------- 同意チェック（送信ボタン直前） ---------- */
.diagnosis-page .consent-block {
  margin: 18px 0 14px;
  padding: 14px;
  border: 1.5px solid #b7cde0;
  border-radius: 10px;
  background: #f7fafc;
}

.diagnosis-page .consent-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}

/* タップ領域44px以上を確保する */
.diagnosis-page .consent-check {
  flex: none;
  width: 24px;
  height: 24px;
  margin: 10px;
  accent-color: #13457B;
  cursor: pointer;
}

.diagnosis-page .consent-text {
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--chat-text);
  padding-top: 8px;
}

.diagnosis-page .consent-text a {
  color: #13457B;
  font-weight: 700;
  text-decoration: underline;
}

.diagnosis-page .consent-hint {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: #8a5a1f;
}

.diagnosis-page .consent-hint.is-satisfied { color: #2f6b55; }

.diagnosis-page .chat-submit-button[disabled] {
  opacity: .45;
  cursor: not-allowed;
}

/* 送信失敗時のメッセージ */
.diagnosis-page .submission-message.is-error {
  color: #8a2318;
  background: #fdf1ef;
  border: 1.5px solid #e6b7b0;
  line-height: 1.8;
}

.diagnosis-page .submission-message.is-error a {
  color: #8a2318;
  font-weight: 700;
  text-decoration: underline;
  word-break: break-all;
}
