/* ── 葵チャットボット スタイル ── */

/* ランチャーボタン */
.chat-launcher {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  z-index: 1000;
}
.chat-launcher__btn {
  width: auto;
  min-width: 58px;
  height: 48px;
  border-radius: 999px;
  background: var(--cta);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0 1.1rem 0 0.85rem;
  box-shadow: 0 4px 20px rgba(78,115,99,0.42);
  transition: transform 0.3s cubic-bezier(.34,1.56,.64,1), box-shadow 0.2s;
  position: relative;
}
.chat-launcher__label {
  color: #fff;
  font-size: 0.78rem;
  font-family: var(--font-gothic);
  font-weight: 500;
  letter-spacing: 0.04em;
  white-space: nowrap;
  transition: opacity 0.18s, max-width 0.25s;
  max-width: 140px;
  overflow: hidden;
}
.chat-launcher__btn.is-open .chat-launcher__label {
  opacity: 0;
  max-width: 0;
  overflow: hidden;
}
.chat-launcher__btn:hover {
  transform: scale(1.07);
  box-shadow: 0 8px 32px rgba(78,115,99,0.52);
}
.chat-launcher__btn:focus-visible {
  outline: 2px solid var(--cta);
  outline-offset: 3px;
}
.chat-launcher__btn.is-open { background: var(--text-secondary); box-shadow: 0 4px 14px rgba(0,0,0,0.18); }

/* アイコンラッパー：絶対配置でオーバーレイ、アイコンが切り替わる */
.chat-launcher__icon-wrap {
  position: relative;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.chat-launcher__btn svg {
  width: 22px; height: 22px; color: #fff;
  position: absolute;
  top: 0; left: 0;
  transition: opacity 0.2s, transform 0.3s cubic-bezier(.34,1.56,.64,1);
}
.icon-chat  { opacity: 1; transform: scale(1) rotate(0deg); }
.icon-close { opacity: 0; transform: scale(0.4) rotate(-90deg); }
.chat-launcher__btn.is-open .icon-chat  { opacity: 0; transform: scale(0.4) rotate(90deg); }
.chat-launcher__btn.is-open .icon-close { opacity: 1; transform: scale(1) rotate(0deg); }
.chat-badge {
  position: absolute; top: -2px; right: -2px;
  width: 17px; height: 17px;
  background: #C0392B; border-radius: 50%;
  border: 2px solid var(--bg-primary);
  font-size: 0.58rem; color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  animation: badge-pulse 2s infinite;
}
@keyframes badge-pulse {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.18); }
}

/* チャットウィンドウ */
.chat-window {
  position: fixed;
  bottom: 5.25rem;
  right: 1.75rem;
  width: 355px;
  max-height: 600px;
  background: var(--bg-card);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(26,25,22,0.17), 0 4px 16px rgba(26,25,22,0.07);
  border: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
  z-index: 999;
  transform-origin: bottom right;
  transform: scale(0.88) translateY(14px);
  opacity: 0; pointer-events: none;
  transition: transform 0.35s cubic-bezier(.34,1.56,.64,1), opacity 0.22s ease;
}
.chat-window.is-open {
  transform: scale(1) translateY(0);
  opacity: 1; pointer-events: auto;
}

/* ヘッダー */
.chat-header {
  background: var(--cta);
  padding: 0.875rem 1.125rem;
  display: flex; align-items: center; gap: 0.7rem;
  flex-shrink: 0; position: relative; overflow: hidden;
}
.chat-header::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.07) 0%, transparent 55%);
  pointer-events: none;
}
.chat-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,0.14);
  border: 1.5px solid rgba(255,255,255,0.32);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mincho); font-size: 1rem; color: #fff;
  flex-shrink: 0; position: relative;
}
.chat-avatar__dot {
  position: absolute; bottom: 1px; right: 1px;
  width: 9px; height: 9px;
  background: #6FCF97; border-radius: 50%;
  border: 1.5px solid var(--cta);
}
.chat-header__name {
  font-family: var(--font-mincho); font-size: 0.9375rem;
  font-weight: 600; color: #fff; letter-spacing: 0.06em; line-height: 1.3;
}
.chat-header__sub {
  font-size: 0.68rem; color: rgba(255,255,255,0.68);
  letter-spacing: 0.07em; font-family: var(--font-latin);
}

/* メッセージエリア */
.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 1.125rem 0.9rem;
  display: flex; flex-direction: column; gap: 0.9rem;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--accent-subtle); border-radius: 2px; }

/* メッセージ */
.chatbot-msg {
  display: flex; gap: 0.55rem; align-items: flex-end;
  animation: chatbot-msg-in 0.32s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes chatbot-msg-in {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.chatbot-msg--bot { align-self: flex-start; }
.chatbot-msg__mini-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--cta);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mincho); font-size: 0.6rem; color: #fff;
  flex-shrink: 0;
}
.chatbot-msg--bot .chatbot-msg__bubble {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 14px 14px 14px 3px;
  padding: 0.65rem 0.85rem;
  font-size: 0.8375rem; line-height: 1.78;
  max-width: 255px;
  word-break: break-all;
  overflow-wrap: break-word;
}
.chatbot-msg--user {
  align-self: flex-end; flex-direction: row-reverse;
}
.chatbot-msg--user .chatbot-msg__bubble {
  background: var(--cta); color: #fff;
  border-radius: 14px 14px 3px 14px;
  padding: 0.65rem 0.85rem;
  font-size: 0.8375rem; line-height: 1.78;
  max-width: 230px;
  word-break: break-all;
  overflow-wrap: break-word;
}
.chatbot-msg__time {
  font-size: 0.62rem; color: var(--text-muted);
  letter-spacing: 0.04em; margin-top: 0.18rem;
}
.chatbot-msg--bot .chatbot-msg__time { padding-left: 32px; }
.chatbot-msg--user .chatbot-msg__time { text-align: right; }

/* 選択肢 */
.chatbot-choices {
  display: flex; flex-direction: column; gap: 0.4rem;
  padding: 0 0.2rem;
  animation: chatbot-msg-in 0.38s cubic-bezier(.34,1.56,.64,1) both;
}
.chatbot-choice-btn {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  font-size: 0.8rem; font-family: var(--font-gothic);
  color: var(--text-primary);
  text-align: left; cursor: pointer; line-height: 1.55;
  transition: border-color 0.16s, background 0.16s, color 0.16s;
  letter-spacing: 0.02em;
}
.chatbot-choice-btn:hover { border-color: var(--accent); background: var(--accent-faint); color: var(--accent); }
.chatbot-choice-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chatbot-choice-btn.is-selected { border-color: var(--cta); background: rgba(78,115,99,0.09); color: var(--cta); pointer-events: none; }
.chatbot-choice-btn:disabled { opacity: 0.45; pointer-events: none; }

/* 結果カード */
.chatbot-result-card {
  background: var(--accent-faint);
  border: 1.5px solid var(--accent-subtle);
  border-radius: 14px;
  padding: 0.95rem 1rem;
  font-size: 0.8rem; line-height: 1.82;
  max-width: 255px; margin-left: 32px;
  animation: chatbot-msg-in 0.4s cubic-bezier(.34,1.56,.64,1) both;
}
.chatbot-result-card__eyebrow {
  font-family: var(--font-latin);
  font-size: 0.62rem; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--accent);
  margin-bottom: 0.3rem; display: block;
}
.chatbot-result-card__title {
  font-family: var(--font-mincho);
  font-size: 1rem; font-weight: 600;
  color: var(--text-primary); letter-spacing: 0.06em;
  margin-bottom: 0.55rem; line-height: 1.4;
}
.chatbot-result-card__body {
  color: var(--text-secondary); font-size: 0.8rem;
  line-height: 1.82;
}
.chatbot-result-card__symptoms {
  margin-top: 0.55rem;
  display: flex; flex-wrap: wrap; gap: 0.3rem;
}
.chatbot-symptom-tag {
  background: rgba(139,115,85,0.1);
  border: 1px solid var(--accent-subtle);
  border-radius: 20px;
  padding: 0.15rem 0.6rem;
  font-size: 0.72rem; color: var(--accent);
  letter-spacing: 0.03em;
}
.chatbot-result-card__look {
  margin-top: 0.6rem;
  padding: 0.5rem 0.65rem;
  background: rgba(255,255,255,0.55);
  border-radius: 8px;
  font-size: 0.75rem; color: var(--text-secondary);
  border-left: 2px solid var(--accent-subtle);
}
.chatbot-result-card__look strong {
  color: var(--accent); font-size: 0.68rem; letter-spacing: 0.12em;
  text-transform: uppercase; display: block; margin-bottom: 0.15rem;
  font-family: var(--font-latin);
}
.chatbot-result-card__btn {
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  width: 100%; margin-top: 0.8rem;
  padding: 0.6rem 1rem;
  background: var(--cta); color: #fff;
  border-radius: 8px; font-size: 0.8rem; font-weight: 500;
  letter-spacing: 0.04em; text-decoration: none;
  transition: background 0.18s; cursor: pointer; border: none;
  font-family: var(--font-gothic);
}
.chatbot-result-card__btn:hover { background: var(--cta-hover); }
.chatbot-result-card__btn:focus-visible { outline: 2px solid var(--cta); outline-offset: 2px; }
.chatbot-result-card__btn--tel {
  background: transparent;
  color: var(--cta);
  border: 1.5px solid var(--cta);
  margin-top: 0.4rem;
  text-decoration: none;
}
.chatbot-result-card__btn--tel:hover { background: rgba(78,115,99,0.08); }
.chatbot-result-card__btn--line {
  background: var(--line-green);
  color: #fff;
  border: none;
  margin-top: 0.4rem;
  text-decoration: none;
}
.chatbot-result-card__btn--line:hover { background: var(--line-green-hover); }

/* タイピング */
.chatbot-typing-wrap {
  display: flex; gap: 0.55rem; align-items: flex-end;
  animation: chatbot-msg-in 0.28s ease both;
}
.chatbot-typing-dots {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 14px 14px 14px 3px;
  padding: 0.65rem 0.85rem;
  display: flex; gap: 4px; align-items: center;
}
.chatbot-typing-dots span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--text-muted);
  animation: chatbot-typing-dot 1.2s infinite;
}
.chatbot-typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.chatbot-typing-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes chatbot-typing-dot {
  0%,60%,100% { transform: translateY(0); opacity: 0.4; }
  30%          { transform: translateY(-5px); opacity: 1; }
}

/* 区切り */
.chatbot-divider {
  text-align: center; font-size: 0.62rem; color: var(--text-muted);
  letter-spacing: 0.12em; font-family: var(--font-latin);
  position: relative;
}
.chatbot-divider::before, .chatbot-divider::after {
  content: ''; position: absolute; top: 50%;
  width: 28%; height: 1px; background: var(--border);
}
.chatbot-divider::before { left: 0; }
.chatbot-divider::after  { right: 0; }

/* 入力エリア */
.chat-input-area {
  padding: 0.75rem 0.875rem;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  display: flex; gap: 0.45rem; align-items: flex-end;
  flex-shrink: 0;
}
.chat-input {
  flex: 1; background: var(--bg-secondary);
  border: 1px solid var(--border); border-radius: 11px;
  padding: 0.55rem 0.8rem; font-size: 0.8375rem;
  font-family: var(--font-gothic); color: var(--text-primary);
  resize: none; outline: none; line-height: 1.5;
  transition: border-color 0.16s;
  max-height: 72px; min-height: 38px;
}
.chat-input::placeholder { color: var(--text-muted); }
.chat-input:focus { border-color: var(--accent-subtle); }
.chat-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chat-send {
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--cta); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.16s, transform 0.16s; flex-shrink: 0;
}
.chat-send:hover { background: var(--cta-hover); transform: scale(1.06); }
.chat-send:focus-visible { outline: 2px solid var(--cta); outline-offset: 2px; }
.chat-send svg { width: 15px; height: 15px; color: #fff; }
.chat-footer {
  padding: 0.35rem 0.875rem 0.65rem;
  text-align: center; font-size: 0.58rem; color: var(--text-muted);
  letter-spacing: 0.06em; background: var(--bg-card); flex-shrink: 0;
}

/* モバイル：固定フッターCTAバーの上に配置 */
@media (max-width: 767px) {
  .chat-launcher {
    bottom: calc(var(--mobile-cta-height, 64px) + 0.75rem);
    right: 1rem;
  }
  .chat-window {
    bottom: calc(var(--mobile-cta-height, 64px) + 4.25rem);
    right: 1rem;
    width: calc(100vw - 2rem);
    max-height: calc(100dvh - var(--mobile-cta-height, 64px) - 6rem);
  }
}

@media (max-width: 420px) {
  .chat-window {
    max-height: calc(100dvh - var(--mobile-cta-height, 64px) - 5.5rem);
  }
}
