/* ─── AIチャットUI（ai-chat.js と連携、既存 .ai-chat-popup/.ai-chat-btn は各ページ側で定義済み） ─── */

/* ポップアップをフレックスレイアウトに上書き */
#ai-popup {
  padding: 0 !important;
  overflow: hidden;
  max-height: 500px;
}
#ai-popup.open {
  display: flex !important;
  flex-direction: column;
}

/* ─── ヘッダ ─── */
.ac-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ac-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.ac-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
  transition: background .2s, color .2s;
}
.ac-close:hover {
  background: rgba(255,255,255,.12);
  color: var(--text);
}

/* ─── メッセージリスト ─── */
.ac-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 120px;
  max-height: 220px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.ac-messages::-webkit-scrollbar { width: 4px; }
.ac-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.ac-msg {
  max-width: 88%;
  font-size: 12px;
  line-height: 1.75;
  padding: 9px 13px;
  border-radius: 14px;
  word-break: break-word;
}
.ac-msg.bot {
  background: rgba(0,87,255,.1);
  border: 1px solid rgba(0,87,255,.18);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.ac-msg.user {
  background: var(--blue);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.ac-msg a {
  color: var(--orange);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ─── サジェストチップ ─── */
.ac-chips {
  padding: 6px 10px 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}
.ac-chip {
  background: rgba(0,87,255,.08);
  border: 1px solid rgba(0,87,255,.25);
  color: var(--blue);
  border-radius: 20px;
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  transition: background .2s, border-color .2s;
  white-space: nowrap;
  line-height: 1.4;
}
.ac-chip:hover {
  background: rgba(0,87,255,.18);
  border-color: rgba(0,87,255,.5);
}

/* ─── 入力欄 ─── */
.ac-input-row {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.ac-input-row input {
  flex: 1;
  min-width: 0;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 12px;
  color: var(--text);
  outline: none;
  font-family: inherit;
  transition: border-color .2s;
}
.ac-input-row input::placeholder { color: var(--muted); }
.ac-input-row input:focus { border-color: var(--blue); }
.ac-input-row button {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: opacity .2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.ac-input-row button:hover { opacity: .82; }

/* ─── スマホ幅調整 ─── */
@media (max-width: 400px) {
  #ai-popup { width: 280px !important; }
}
