/* ===== チャットボット ===== */

/* 配置の枠 */
.chat-widget {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-w);
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  z-index: 100;
  pointer-events: none;
}

/* --- ウィンドウ --- */
.chat-panel {
  pointer-events: auto;
  width: 100%;
  max-width: 360px;
  height: min(60vh, 460px);
  background: var(--light);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(44, 36, 30, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* 閉じている状態 */
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}

/* 開いた状態 */
.chat-widget.is-open .chat-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ヘッダー */
.chat-head {
  background: var(--accent);
  color: var(--white);
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-title {
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: 0.04em;
}
.chat-close {
  background: none;
  border: none;
  color: var(--white);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  opacity: 0.85;
}
.chat-close:hover { opacity: 1; }

/* 会話エリア */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 吹き出し */
.msg {
  max-width: 80%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
}
.msg-bot {
  align-self: flex-start;
  background: var(--white);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--white);
  border-bottom-right-radius: 4px;
}

/* 入力欄 */
.chat-form {
  display: flex;
  gap: 8px;
  padding: 11px 12px;
  background: var(--white);
  border-top: 1px solid var(--warm);
}
.chat-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--warm);
  border-radius: 20px;
  padding: 9px 14px;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text);
  background: var(--light);
}
.chat-input:focus {
  outline: none;
  border-color: var(--accent);
}
.chat-send {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--white);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.chat-send:hover { background: var(--accent-dark); }
.chat-send svg { width: 17px; height: 17px; }

/* --- トリガーボタン --- */
.chat-trigger {
  pointer-events: auto;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--white);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(44, 36, 30, 0.25);
  transition: transform 0.2s ease, background 0.2s ease;
}
.chat-trigger:hover {
  background: var(--accent-dark);
  transform: translateY(-2px);
}
.chat-trigger svg { width: 26px; height: 26px; }

/* 開いているときはアイコンを×に入れ替える */
.chat-icon-close { display: none; }
.chat-widget.is-open .chat-icon-open { display: none; }
.chat-widget.is-open .chat-icon-close { display: block; }

@media (prefers-reduced-motion: reduce) {
  .chat-panel, .chat-trigger { transition: none; }
}
.chat-trigger:focus-visible,
.chat-send:focus-visible,
.chat-close:focus-visible {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
}
/* 応答待ちの表示 */
.msg.is-thinking { color: var(--gray); font-style: italic; }
.chat-input:disabled { opacity: 0.6; }
.chat-send:disabled { opacity: 0.5; cursor: default; }