/* AIチャットボット。ブランド青(--primary)/緑(--secondary)を控えめにアクセント。 */

.yl-ai { position: fixed; z-index: 951; }

/* 起動ボタン（右下・追従CTAの下に収まる位置） */
.yl-ai__launch { position: fixed; right: 20px; bottom: 20px; z-index: 951;
  display: inline-flex; align-items: center; gap: .5rem; padding: .6rem .95rem .6rem .8rem;
  background: var(--ink); color: #fff; border: 0; border-radius: 999px; cursor: pointer;
  font-family: var(--body, sans-serif); font-size: .82rem; font-weight: 700; letter-spacing: .02em;
  box-shadow: 0 8px 22px rgba(20, 28, 38, .28); transition: background .2s, transform .2s, opacity .2s; }
.yl-ai__launch:hover { background: var(--primary, #005BAC); transform: translateY(-1px); }
.yl-ai__launch-ic { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: rgba(255, 255, 255, .16); flex: 0 0 auto; }
.yl-ai__launch-ic svg { width: 18px; height: 18px; }
.yl-ai[data-open="true"] .yl-ai__launch { opacity: 0; pointer-events: none; transform: scale(.9); }

/* パネル */
.yl-ai__panel { position: fixed; right: 20px; bottom: 20px; z-index: 1001;
  width: min(370px, calc(100vw - 32px)); max-height: min(74vh, 620px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface, #fff); border: 1px solid var(--outline-variant, #e3e6ea); border-radius: 18px;
  box-shadow: 0 24px 60px rgba(18, 26, 38, .3);
  transform-origin: bottom right; animation: yl-ai-in .22s ease; }
@keyframes yl-ai-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

.yl-ai__head { display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .8rem 1rem; color: #fff;
  background: linear-gradient(120deg, var(--primary, #005BAC), color-mix(in srgb, var(--primary, #005BAC) 62%, var(--secondary, #4CAF50))); }
.yl-ai__title { display: inline-flex; align-items: center; gap: .5rem; font-family: var(--display, sans-serif); font-weight: 700; font-size: .95rem; }
.yl-ai__dot { width: 8px; height: 8px; border-radius: 50%; background: #7CFFB2; box-shadow: 0 0 0 0 rgba(124, 255, 178, .7); animation: yl-ai-pulse 2s infinite; }
@keyframes yl-ai-pulse { 0% { box-shadow: 0 0 0 0 rgba(124, 255, 178, .6); } 70% { box-shadow: 0 0 0 7px rgba(124, 255, 178, 0); } 100% { box-shadow: 0 0 0 0 rgba(124, 255, 178, 0); } }
.yl-ai__close { display: grid; place-items: center; width: 34px; height: 34px; background: rgba(255, 255, 255, .14); border: 0; color: #fff; font-size: 1.5rem; line-height: 1; cursor: pointer; border-radius: 50%; opacity: .95; transition: background .15s, opacity .15s; }
.yl-ai__close:hover { opacity: 1; background: rgba(255, 255, 255, .3); }

.yl-ai__log { flex: 1 1 auto; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .55rem;
  background: color-mix(in srgb, var(--surface, #fff) 92%, var(--soft-sky, #eef4fb)); }
.yl-ai__msg { max-width: 84%; padding: .6rem .8rem; border-radius: 14px; font-family: var(--body, sans-serif); font-size: .84rem; line-height: 1.6; word-break: break-word; }
.yl-ai__msg--bot { align-self: flex-start; background: #fff; color: var(--ink, #1c2126); border: 1px solid var(--outline-variant, #e3e6ea); border-bottom-left-radius: 5px; }
.yl-ai__msg--user { align-self: flex-end; background: var(--primary, #005BAC); color: #fff; border-bottom-right-radius: 5px; }
.yl-ai__msg a { color: inherit; text-decoration: underline; }
.yl-ai__msg--bot a { color: var(--primary, #005BAC); }

.yl-ai__sources { align-self: flex-start; display: flex; flex-wrap: wrap; gap: .35rem; margin: -.2rem 0 .1rem; }
.yl-ai__src { font-size: .72rem; font-weight: 600; color: var(--primary, #005BAC); background: color-mix(in srgb, var(--primary, #005BAC) 10%, #fff);
  border: 1px solid color-mix(in srgb, var(--primary, #005BAC) 26%, #fff); border-radius: 999px; padding: .22rem .6rem; text-decoration: none; }
.yl-ai__src:hover { background: color-mix(in srgb, var(--primary, #005BAC) 18%, #fff); }

/* タイピングインジケータ */
.yl-ai__typing { display: inline-flex; gap: 4px; align-items: center; }
.yl-ai__typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-soft, #8a929c); animation: yl-ai-bounce 1.2s infinite ease-in-out; }
.yl-ai__typing span:nth-child(2) { animation-delay: .15s; }
.yl-ai__typing span:nth-child(3) { animation-delay: .3s; }
@keyframes yl-ai-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* サジェストチップ */
.yl-ai__suggests { display: flex; flex-wrap: wrap; gap: .4rem; padding: .5rem 1rem 0; }
.yl-ai__chip { font-family: var(--body, sans-serif); font-size: .74rem; font-weight: 600; color: var(--ink, #1c2126);
  background: #fff; border: 1px solid var(--outline-variant, #e3e6ea); border-radius: 999px; padding: .32rem .7rem; cursor: pointer; transition: border-color .15s, color .15s; }
.yl-ai__chip:hover { border-color: var(--primary, #005BAC); color: var(--primary, #005BAC); }

/* 入力 */
.yl-ai__form { display: flex; align-items: flex-end; gap: .5rem; padding: .7rem 1rem .5rem; }
.yl-ai__input { flex: 1 1 auto; resize: none; max-height: 110px; padding: .55rem .7rem; font-family: var(--body, sans-serif); font-size: .84rem; line-height: 1.5;
  color: var(--ink, #1c2126); background: #fff; border: 1px solid var(--outline-variant, #e3e6ea); border-radius: 12px; outline: none; }
.yl-ai__input:focus { border-color: var(--primary, #005BAC); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary, #005BAC) 18%, transparent); }
.yl-ai__send { flex: 0 0 auto; width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--primary, #005BAC); color: #fff; transition: background .15s; }
.yl-ai__send:hover { background: color-mix(in srgb, var(--primary, #005BAC) 85%, #000); }
.yl-ai__send svg { width: 18px; height: 18px; }
.yl-ai__note { margin: 0; padding: 0 1rem .7rem; font-size: .66rem; color: var(--ink-soft, #8a929c); text-align: center; }

/* モバイル：下部固定ナビ(.yl-fixnav)や追従CTAと重ならないよう左下＋ボトムシート化 */
@media (max-width: 768px) {
  .yl-ai__launch { right: auto; left: 14px; bottom: 74px; }
  .yl-ai__panel { right: 0; left: 0; bottom: 0; width: 100%; max-height: 82vh; border-radius: 18px 18px 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  .yl-ai__panel { animation: none; }
  .yl-ai__dot, .yl-ai__typing span { animation: none; }
}
