/* オーバーレイ */
#overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(3px);
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding-top: 80px;
  z-index: 9999;
}

#resultsPanel {
  background: white;
  width: 80%;
  height: 80%;
  border-radius: 12px;
  padding: 20px 30px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  animation: fadeIn 0.25s ease-out;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#results {
  flex: 1;
  overflow-y: auto;
  height: 100%;
  min-height: 0;
}


/* アニメーション */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* モダンリンク */
.result-item a {
  display: block;
  padding: 10px 14px;
  background: #f7f7f9;
  border-radius: 8px;
  text-decoration: none;
  color: #333;
  font-weight: 600;
  transition: all 0.18s ease;
  border: 1px solid #e5e5e5;
}

.result-item a:hover {
  background: #ffffff;
  border-color: #c8c8c8;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
#loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255,255,255,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 6px solid #ddd;
  border-top-color: #4a90e2;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#ai-chat-container {
   position: fixed;
  bottom: 20px;
  right: 20px;
  width: 400px;
  height: 600px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  flex-direction: column;   /* ← flex-direction は残してOK */
  overflow: hidden;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: none;   /* ← 初期は閉じておく（これだけでOK） */
}

#ai-chat-header {
  background: #4a90e2;
  color: white;
  padding: 12px;
  font-size: 1.1em;
}

#ai-chat-window {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  background: #f7f7f7;
}

.ai-msg, .user-msg {
  max-width: 80%;
  padding: 10px 14px;
  margin-bottom: 14px;
  border-radius: 10px;
  white-space: pre-wrap;
  line-height: 1.6;
}

.user-msg {
  background: #d0eaff;
  margin-left: auto;
}

.ai-msg {
  background: #ffffff;
  border: 1px solid #ddd;
}

.ref-box {
  margin-top: 8px;
  padding: 8px;
  background: #fafafa;
  border-left: 4px solid #4a90e2;
  font-size: 0.85em;
}

/* 入力エリア */
#ai-chat-input-area {
  display: flex;
  padding: 10px;
  background: #fff;
  border-top: 1px solid #ddd;
}

#ai-chat-input {
  flex: 1;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
}

#ai-chat-send {
  margin-left: 8px;
  padding: 10px 16px;
  background: #4a90e2;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

/* フローティングボタン */
#ai-chat-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  background: #4a90e2;
  border-radius: 50%;
  display: none;
  justify-content: center;
  align-items: center;
  color: white;
  font-size: 28px;
  cursor: pointer;
  z-index: 2147483647;
  display: flex;  /* ← 初回はこれが必要 */
}

/* ヘッダー（タイトル左・ボタン右） */
#ai-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
}

/* ボタンをまとめて右側に並べる */
.chat-btn-group {
  display: flex;
  gap: 14px;   /* ← これが確実に隙間を作る */
}

/* ボタンの見た目 */
.chat-btn {
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
  user-select: none;
}

.chat-btn:hover {
  background: #e0e0e0;
}

/* ローディング（目立つ版） */
#ai-chat-loading {
  background: #ffe9a8;
  color: #8a4b00;
  padding: 10px;
  text-align: center;
  font-weight: bold;
  border-top: 2px solid #ffcc4d;
  border-bottom: 2px solid #ffcc4d;
  animation: blink 1s infinite;
}

#ai-chat-loading.hidden {
  display: none;
}

@keyframes blink {
  0% { opacity: 0.2; }
  50% { opacity: 1; }
  100% { opacity: 0.2; }
}

/* 初期メッセージ */
.ai-initial {
  opacity: 0.8;
  font-style: italic;
  margin-bottom: 12px;
}

/* 拡大モード */
#ai-chat-container.large {
  width: 700px !important;
  height: 800px !important;
}
#ai-chat-send.disabled {
  background: #9bbce0;
  cursor: not-allowed;
  opacity: 0.6;
}

#ai-chat-tip {
  position: fixed;
  bottom: 90px;
  right: 20px;
  background: #1e6fff; /* 濃い青で存在感 */
  padding: 8px 12px;
  border-radius: 8px;
  box-shadow: 0 0 18px rgba(30, 111, 255, 0.45); /* 青い光をまとわせる */
  color: white;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 2147483647; /* ← toggle と同じ最前面にする */
}


@keyframes tip-pop-slide {
  0%   { transform: translateY(10px) scale(0.6); opacity: 0; }
  60%  { transform: translateY(-2px) scale(1.15); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}




@keyframes chat-pop {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}



@keyframes tip-big-pop {
  0%   { transform: translateY(10px) scale(0.4); opacity: 0; }
  35%  { transform: translateY(-6px) scale(1.45); opacity: 1; }
  65%  { transform: translateY(2px) scale(0.85); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

#ai-chat-tip.show {
  opacity: 1;
  animation: tip-big-pop 0.55s cubic-bezier(.25,1.4,.35,1);
}
