/* ====================================================================
 * AI ガイド「サクラ」スタイル
 * 個別化 HP 共通モジュール (LocalDive)
 *
 * - 既存 chat-ryokan FAB (右下 z-index 8800) と物理分離 → サクラは左下 7900
 * - スプライト PNG が無い場合は CSS-only 円形アバターにフォールバック
 * - prefers-reduced-motion 配慮
 * ==================================================================== */

:root {
  --ldai-pink: #f8bbd0;
  --ldai-pink-deep: #e91e63;
  --ldai-pink-light: #fce4ec;
  --ldai-ink: #2b2e3a;
  --ldai-bg: #fffafc;
  --ldai-shadow: 0 10px 30px rgba(233, 30, 99, 0.18), 0 4px 12px rgba(0, 0, 0, 0.10);
}

/* ---------- アバター本体 ----------
   z-index: 10001 — ld-demo-banner(9999) と ld-quick-diagnosis(10000) を上回らないと
   左下に重ねた他モジュールに物理的に隠されて気づけない (2026-05-27 修正) */
.ldai-avatar {
  position: fixed;
  left: 24px;
  bottom: 24px;
  width: 14vw;
  min-width: 200px;
  max-width: 280px;
  z-index: 10001;
  font-family: -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  pointer-events: none;
  transform-origin: bottom left;
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1),
              opacity 0.4s ease,
              width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
/* breath animation: 静止画でも生きているように見せる軽い呼吸 */
.ldai-avatar__body {
  animation: ldai-breath 4.2s ease-in-out infinite;
  will-change: transform;
  position: relative;
}
@keyframes ldai-breath {
  0%, 100% { transform: translateY(0) scale(1) rotate(0deg); }
  25%      { transform: translateY(-1px) scale(1.008) rotate(-0.3deg); }
  50%      { transform: translateY(-2px) scale(1.012) rotate(0deg); }
  75%      { transform: translateY(-1px) scale(1.008) rotate(0.3deg); }
}

/* 音量パルス glow（控えめ、 mouth-open 値に応じて外周がほのかに脈打つ） */
.ldai-avatar__body::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 24px;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(
    closest-side,
    rgba(233, 30, 99, calc(0.10 + var(--mouth-open, 0) * 0.06)) 0%,
    rgba(233, 30, 99, 0) 70%
  );
  transition: background 0.08s ease-out;
}

/* まばたきオーバーレイ: 顔全体を一瞬わずかに暗く（実物の目を閉じる代わり） */
.ldai-avatar__blink {
  position: absolute;
  inset: 0;
  background: rgba(20, 10, 20, 0);
  pointer-events: none;
  border-radius: inherit;
  animation: ldai-face-blink 5.8s ease-in-out infinite;
}
@keyframes ldai-face-blink {
  0%, 93%, 100% { background: rgba(20, 10, 20, 0); }
  95%, 97%      { background: rgba(20, 10, 20, 0.18); }
}

/* リップシンク表現: 音量に応じて顔全体をほんのり明るく光らせる。
   transform は breath animation が独占するので、 filter brightness で代用。 */
.ldai-avatar__body {
  filter:
    brightness(calc(1 + var(--mouth-open, 0) * 0.04))
    saturate(calc(1 + var(--mouth-open, 0) * 0.06));
  transition: filter 0.08s ease-out;
}
.ldai-avatar.is-entering {
  animation: ldai-slide-in 0.9s cubic-bezier(0.2, 0.9, 0.3, 1.1) forwards;
}

/* ナレーション終了 → FAB 化の遷移途中のフェードアウト演出。
 * JS が一時的に is-fading を付与し、 350ms 後に is-shrunk に切替える。 これで
 * 「video が突然消えて FAB が出現」という違和感を消し、 滑らかに次形態へ繋ぐ。 */
.ldai-avatar.is-fading .ldai-bubble {
  transition: opacity 0.32s ease, transform 0.32s ease;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
}
.ldai-avatar.is-fading .ldai-avatar__video {
  transition: opacity 0.32s ease, filter 0.32s ease;
  opacity: 0.15;
  filter: saturate(0.6);
}
.ldai-avatar.is-fading .ldai-avatar__frame {
  transition: opacity 0.32s ease;
  opacity: 0.15;
}
.ldai-avatar.is-fading .ldai-avatar__body {
  transition: filter 0.32s ease;
  filter: brightness(0.96);
}
@keyframes ldai-slide-in {
  0%   { transform: translateX(-110%) translateY(8px); opacity: 0; }
  60%  { transform: translateX(0) translateY(-4px); opacity: 1; }
  100% { transform: translateX(0) translateY(0); opacity: 1; }
}

/* ---------- アバター画像（スプライトまたはフォールバック） ---------- */
.ldai-avatar__body {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 18px;
  overflow: hidden;
  pointer-events: auto;
  background: linear-gradient(160deg, var(--ldai-pink-light) 0%, #fff 60%, var(--ldai-pink) 100%);
  box-shadow: var(--ldai-shadow);
}
.ldai-avatar__body[data-has-sprite="true"] {
  /* スプライト PNG 採用時。1080×375 を 4 frame 横並びで割る:
   *   frame 0: mouth_closed (口閉)
   *   frame 1: mouth_half   (口半開)
   *   frame 2: mouth_open   (口全開)
   *   frame 3: eyes_closed  (まばたき)
   * 実際の frame 切替は 2 layer crossfade (.ldai-avatar__frame--a/--b の opacity) で行う。
   * 単一 background-image は CSS-only フォールバック（JS が DOM を作る前のチラ見え対策）として残す。
   */
  background-image: url("./images/sakura-sprites.png");
  background-size: 400% 100%;
  background-position-x: 0%;
  background-position-y: 0%;
  background-repeat: no-repeat;
  background-color: #fff;
}

/* 2-layer crossfade: .ldai-avatar__frame--a と --b に異なる frame をセットし
 * opacity を 0.12s で補間することで「右から左に滑走」現象を消す。
 * JS の setMouthAndFrame() が active layer を切替えて呼び出す。 */
.ldai-avatar__body[data-has-sprite="true"] .ldai-avatar__frame {
  position: absolute;
  inset: 0;
  background-image: url("./images/sakura-sprites.png");
  background-size: 400% 100%;
  background-position-y: 0%;
  background-repeat: no-repeat;
  transition: opacity 0.12s linear;
  pointer-events: none;
  will-change: opacity;
  z-index: 2;
}
.ldai-avatar__body[data-has-sprite="true"] .ldai-avatar__frame--a {
  background-position-x: calc(var(--frame-a, 0) * 33.333%);
}
.ldai-avatar__body[data-has-sprite="true"] .ldai-avatar__frame--b {
  background-position-x: calc(var(--frame-b, 0) * 33.333%);
}

/* 単一画像モード（スプライト無し、1 枚 PNG で表示）。
   背景画像 URL は ai-guide.js が `--ldai-avatar-img` カスタムプロパティで variant 別に注入する。
   transform 系は .ldai-avatar__body の breath + リップシンク section で統合管理。 */
.ldai-avatar__body[data-has-sprite="single"] {
  background-image: var(--ldai-avatar-img, url("./images/sakura_A.png"));
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  background-color: #fff;
}
/* 2026-05-27: single モードでは旧 sprite の frame layer (./images/sakura-sprites.png) を完全に隠す。
   これで「frame layer の透過 PNG が顔の上でチラつく」事故を防ぐ。 */
.ldai-avatar__body[data-has-sprite="single"] .ldai-avatar__frame { display: none; }

/* ---------- 口リップシンク overlay (2026-06-03 恒久無効化) ----------
   【根本原因 / 再発防止】この overlay は「暗色だ円を画像上の固定 % 位置 (top:49.5%) に
   被せて scaleY で開閉」する方式だった。位置はアバター画像 (sakura_*.png) の口位置と
   カード枠の構図に依存してハードコードされており、画像や variant・枠サイズが変わるたびに
   口とズレ、「口の下に黒いパーツがパクパク動く」気持ち悪い表示になる事故が繰り返し発生した
   (2026-06-03 森報告。過去にも同症状)。
   画像位置依存の overlay は本質的に壊れやすいため廃止。リップシンクは画像非依存で安全な
   「音量に応じた控えめな glow / brightness パルス」(.ldai-avatar__body::after / filter) のみで表現する。
   将来きちんとした口パクを足す場合も、固定 % 位置の暗色オーバーレイ方式は再採用しないこと。 */
.ldai-avatar__mouth-overlay { display: none !important; }

/* スプライト無い場合の CSS-only 表現: 桜の絵文字 + テキスト */
.ldai-avatar__body[data-has-sprite="false"]::before {
  content: "🌸";
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(48px, 9vw, 96px);
}
.ldai-avatar__body[data-has-sprite="false"]::after {
  content: "サクラ";
  position: absolute;
  left: 50%;
  bottom: 12%;
  transform: translateX(-50%);
  font-size: clamp(13px, 1.4vw, 17px);
  font-weight: 600;
  color: var(--ldai-pink-deep);
  letter-spacing: 0.1em;
}

/* 口パク状態管理。 sprite モードは --frame を JS から直接設定（上の rule で参照済）。 */
.ldai-avatar__body {
  --mouth-open: 0;
}

/* ---------- video モード（HeyGen Avatar IV MP4）---------- */
/* video が存在する HP では <video> がアバター本体になる。
 * sprite frame / CSS-only fallback / filter brightness はすべて無効化し、
 * <video> + 瞬き overlay（CSS で目を閉じる演出）だけが表示される。 */
.ldai-avatar__body[data-has-video="true"] {
  background-image: none;
  filter: none;
}
.ldai-avatar__body[data-has-video="true"] .ldai-avatar__frame,
.ldai-avatar__body[data-has-video="true"] .ldai-avatar__eyes,
.ldai-avatar__body[data-has-video="true"] .ldai-avatar__blink {
  display: none;
}
.ldai-avatar__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: inherit;
  background: #FFFAFC;
  z-index: 1;
  display: block;
  opacity: 1;
  /* is-shrunk 付与時に opacity 0 へ遷移。 fab-bg と同時並行 → クロスフェード */
  transition: opacity 0.65s cubic-bezier(0.4, 0, 0.2, 1);
}
/* video モード時の FAB 静止画レイヤー。 通常は opacity 0、 is-shrunk で 1 にクロスフェードイン。
 * これがあると「video が薄れる ↔ sakura_B.png が現れる」が滑らかに重なる。 */
.ldai-avatar__fab-bg {
  position: absolute;
  inset: 0;
  background: url("./images/sakura_B.png") center 22% / cover no-repeat;
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.65s cubic-bezier(0.4, 0, 0.2, 1);
}
/* 瞬き overlay rule は実装上の参考として残置。
 * 現状: ai-guide.js が DOM 要素を生成しないため適用されない（無効）。
 * 理由: anime 調 sakura_B の眼にこの ellipse を重ねると「肌が眼に貼り付く」不自然な絵になるため。
 * 自然な瞬きを実装する場合は (1) フォトリアル Sakura を生成し直して HeyGen 側で natural blink を出す、
 * または (2) gpt-image-2 で eye_closed 派生画像を作って transition 化、の 2 ルートになる。 */
.ldai-avatar__video-blink {
  position: absolute;
  background: linear-gradient(180deg, #E0BA9A 0%, #C8A082 100%);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transform: scaleY(0.05);
  transform-origin: top center;
  animation: ldai-video-blink 5.4s ease-in-out infinite;
  z-index: 2;
  will-change: opacity, transform;
}
.ldai-avatar__video-blink--left {
  top: 26%;
  left: 35.5%;
  width: 9%;
  height: 4.2%;
}
.ldai-avatar__video-blink--right {
  top: 26%;
  left: 55.5%;
  width: 9%;
  height: 4.2%;
  animation-delay: 0.03s;
}
@keyframes ldai-video-blink {
  0%, 93%, 100% { opacity: 0; transform: scaleY(0.05); }
  94.8%, 96.2% { opacity: 0.95; transform: scaleY(1); }
}

/* sprite モードはスプライト内に実際の表情が描かれているので、
   filter brightness や blink overlay は無効化（二重表現の違和感を回避）。 */
.ldai-avatar__body[data-has-sprite="true"] {
  filter: none;
}
.ldai-avatar__body[data-has-sprite="true"] .ldai-avatar__blink,
.ldai-avatar__body[data-has-sprite="true"] .ldai-avatar__eyes {
  display: none;
}

/* まばたき（CSS のみで定常的に） */
.ldai-avatar__eyes {
  position: absolute;
  inset: 28% 30% auto 30%;
  height: 6%;
  pointer-events: none;
  opacity: 0;
}
.ldai-avatar__eyes::before,
.ldai-avatar__eyes::after {
  content: "";
  position: absolute;
  top: 0;
  width: 28%;
  height: 100%;
  background: var(--ldai-ink);
  border-radius: 50%;
  transform: scaleY(1);
  animation: ldai-blink 5.2s ease-in-out infinite;
}
.ldai-avatar__eyes::before { left: 10%; }
.ldai-avatar__eyes::after  { right: 10%; }
@keyframes ldai-blink {
  0%, 92%, 100% { transform: scaleY(0.1); opacity: 0; }
  93%, 99%      { transform: scaleY(1);   opacity: 0.85; }
}

/* ---------- speech bubble ---------- */
.ldai-bubble {
  position: relative;
  margin: 14px 0 0 0;
  padding: 14px 16px 12px 14px;
  background: var(--ldai-bg);
  border: 1px solid var(--ldai-pink);
  border-radius: 14px;
  box-shadow: var(--ldai-shadow);
  pointer-events: auto;
  font-size: clamp(13px, 1.05vw, 15px);
  line-height: 1.55;
  color: var(--ldai-ink);
}
.ldai-bubble__tag {
  display: inline-block;
  font-size: 0.78em;
  font-weight: 600;
  color: var(--ldai-pink-deep);
  background: var(--ldai-pink-light);
  border-radius: 999px;
  padding: 2px 9px;
  margin-bottom: 8px;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.ldai-bubble__name {
  font-size: 0.78em;
  font-weight: 500;
  color: #888;
  margin-left: 6px;
  white-space: nowrap;
  word-break: keep-all;
}
.ldai-bubble__text {
  white-space: pre-wrap;
  min-height: 2.6em;
}
.ldai-bubble__close,
.ldai-bubble__mute {
  position: absolute;
  top: 6px;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #888;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ldai-bubble__close { right: 6px; }
.ldai-bubble__mute  { right: 36px; font-size: 15px; }
.ldai-bubble__close:hover,
.ldai-bubble__mute:hover { background: var(--ldai-pink-light); color: var(--ldai-pink-deep); }

/* ---------- 縮小（FAB 化）後 ---------- */
.ldai-avatar.is-shrunk {
  width: 64px;
  min-width: 64px;
  max-width: 64px;
  cursor: pointer;
  pointer-events: auto;
}
.ldai-avatar.is-shrunk .ldai-bubble { display: none; }
.ldai-avatar.is-shrunk .ldai-avatar__body {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  aspect-ratio: 1 / 1;
  animation: ldai-fab-pulse 2.4s ease-out infinite;
}
/* shrunk FAB ではスプライト strip を 64x64 円にクロップできないので、
   静止画 (sakura_B.png) をそのまま顔中心で cover 表示する。
   crossfade 用の 2-layer も FAB 時は隠す（背景画像 override が機能するように）。 */
.ldai-avatar.is-shrunk .ldai-avatar__body[data-has-sprite="true"] {
  background-image: url("./images/sakura_B.png");
  background-size: cover;
  background-position: center 22%;
  background-color: #fff;
}
.ldai-avatar.is-shrunk .ldai-avatar__frame { display: none; }
/* video モード時の FAB: <video> を opacity 0 にフェードアウト、 fab-bg (sakura_B.png) を 1 にフェードイン。
 * display:none に切替えると瞬時に消えるので、 opacity transition で滑らかなクロスフェードを担保する。 */
.ldai-avatar.is-shrunk .ldai-avatar__body[data-has-video="true"] {
  background-color: #fff;
}
.ldai-avatar.is-shrunk .ldai-avatar__video {
  opacity: 0;
}
.ldai-avatar.is-shrunk .ldai-avatar__fab-bg {
  opacity: 1;
}
.ldai-avatar.is-shrunk .ldai-avatar__video-blink {
  display: none;
}
/* glow pulse は FAB の ldai-fab-pulse box-shadow に役目を譲るので消す */
.ldai-avatar.is-shrunk .ldai-avatar__body::after { display: none; }
.ldai-avatar.is-shrunk .ldai-avatar__body[data-has-sprite="false"]::before {
  font-size: 30px;
  top: 50%;
  transform: translate(-50%, -55%);
}
.ldai-avatar.is-shrunk .ldai-avatar__body[data-has-sprite="false"]::after {
  display: none;
}
.ldai-avatar.is-shrunk .ldai-avatar__eyes { display: none; }
.ldai-avatar.is-shrunk .ldai-avatar__fab-label {
  position: absolute;
  left: 80px;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  background: var(--ldai-ink);
  color: #fff;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.ldai-avatar.is-shrunk:hover .ldai-avatar__fab-label,
.ldai-avatar.is-shrunk.is-hint-visible .ldai-avatar__fab-label {
  opacity: 1;
  transform: translateY(-50%) translateX(4px);
}
@keyframes ldai-fab-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(233, 30, 99, 0.45); }
  70%  { box-shadow: 0 0 0 18px rgba(233, 30, 99, 0); }
  100% { box-shadow: 0 0 0 0 rgba(233, 30, 99, 0); }
}

/* ---------- glow（CTA 強調） ---------- */
.ldai-glow {
  animation: ldai-glow 1.5s ease-in-out 3 alternate !important;
  position: relative;
  z-index: 100;
}
@keyframes ldai-glow {
  0%   { box-shadow: 0 0 0 0 rgba(255, 196, 0, 0); }
  50%  { box-shadow: 0 0 0 12px rgba(255, 196, 0, 0.55); }
  100% { box-shadow: 0 0 0 0 rgba(255, 196, 0, 0); }
}

/* ---------- autoplay 不可時の起動バナー（中央・目立つ）---------- */
.ldai-banner {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  background: linear-gradient(135deg, var(--ldai-pink-deep) 0%, #ff6f9c 100%);
  color: #fff;
  padding: 22px 40px 22px 32px;
  border-radius: 999px;
  box-shadow: 0 20px 60px rgba(233, 30, 99, 0.4), 0 8px 22px rgba(0, 0, 0, 0.25);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.04em;
  font-family: -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  animation: ldai-banner-in 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.1) forwards,
             ldai-banner-pulse 2.4s ease-out 0.5s infinite;
  max-width: calc(100vw - 48px);
  white-space: nowrap;
}
@keyframes ldai-banner-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes ldai-banner-pulse {
  0%, 100% { box-shadow: 0 20px 60px rgba(233, 30, 99, 0.4), 0 0 0 0 rgba(233, 30, 99, 0.6); }
  50%      { box-shadow: 0 20px 60px rgba(233, 30, 99, 0.4), 0 0 0 18px rgba(233, 30, 99, 0); }
}
.ldai-banner__icon { font-size: 22px; }
.ldai-banner__name,
.ldai-banner__action,
.ldai-banner__sub { white-space: nowrap; }
.ldai-banner__sub { font-size: 0.78em; font-weight: 500; opacity: 0.85; margin-left: 6px; }
/* デスクトップでは「AI サクラ」と「の案内を聞く」の間の改行を無効化（1 行表示） */
.ldai-banner__br { display: none; }
@media (max-width: 640px) {
  .ldai-banner {
    font-size: 15px;
    padding: 18px 26px 18px 22px;
    /* モバイルではテキストを 2 行に折る (「AI サクラ」 + 「の案内を聞く（約 50 秒）」)。
       white-space は子要素ごと nowrap で個別管理し、 banner 自体は wrap を許可。 */
    white-space: normal;
    text-align: center;
    max-width: calc(100vw - 32px);
    /* icon と text を 縦並びに（icon は 1 行目に組み込みつつ、本文の改行は br で明示） */
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 4px;
  }
  /* モバイル時のみ 1 行目「▶ AI サクラ」、 2 行目「の案内を聞く（約 50 秒）」になるよう改行を有効化 */
  .ldai-banner__br { display: block; flex-basis: 100%; height: 0; }
  /* 2 行目の「の案内を聞く」と「（約 50 秒）」は横一列のまま */
  .ldai-banner__sub { margin-left: 4px; }
}

/* ---------- Q&A モーダル ---------- */
.ldai-modal {
  position: fixed;
  left: 24px;
  bottom: 100px;
  width: min(380px, calc(100vw - 48px));
  max-height: 70vh;
  z-index: 7950;
  background: #fff;
  border: 1px solid var(--ldai-pink);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  animation: ldai-modal-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.05);
}
@keyframes ldai-modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.ldai-modal__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: linear-gradient(135deg, var(--ldai-pink-light) 0%, #fff 100%);
  border-bottom: 1px solid var(--ldai-pink);
}
.ldai-modal__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ldai-ink);
}
.ldai-modal__close {
  margin-left: auto;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #888;
  font-size: 18px;
  cursor: pointer;
}
.ldai-modal__close:hover { background: var(--ldai-pink-light); color: var(--ldai-pink-deep); }
.ldai-modal__body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ldai-ink);
}
.ldai-modal__msg { margin: 0 0 10px 0; padding: 9px 12px; border-radius: 10px; }
.ldai-modal__msg--user { background: var(--ldai-pink-light); margin-left: 24px; }
.ldai-modal__msg--bot  { background: #f4f5f8; margin-right: 24px; }
.ldai-modal__form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #eee;
  background: #fafbfc;
}
.ldai-modal__input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13.5px;
  outline: none;
  font-family: inherit;
}
.ldai-modal__input:focus { border-color: var(--ldai-pink-deep); }
.ldai-modal__submit {
  border: none;
  background: var(--ldai-pink-deep);
  color: #fff;
  border-radius: 999px;
  padding: 0 16px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
}
.ldai-modal__submit:hover { background: #c2185b; }
.ldai-modal__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px 0 12px;
}
.ldai-modal__suggestion {
  font-size: 11.5px;
  background: var(--ldai-pink-light);
  color: var(--ldai-pink-deep);
  border: none;
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
}
.ldai-modal__suggestion:hover { background: var(--ldai-pink); color: #fff; }

/* ---------- スマホ ---------- */
@media (max-width: 640px) {
  .ldai-avatar {
    /* スマホでは bubble をアバター下に十分長く取れるよう、 アバター本体を小さめに */
    width: 38vw;
    min-width: 130px;
    max-width: 170px;
    left: 12px;
    bottom: 12px;
  }
  .ldai-avatar.is-shrunk {
    width: 56px;
    min-width: 56px;
    max-width: 56px;
    left: 12px;
    bottom: 12px;
  }
  .ldai-avatar.is-shrunk .ldai-avatar__body { width: 56px; height: 56px; }
  .ldai-avatar.is-shrunk .ldai-avatar__fab-label { display: none; }
  .ldai-bubble {
    /* アバターより少し広げて、 アイコンとテキストが重ならないよう padding を確保 */
    width: 78vw;
    max-width: 320px;
    margin-top: 10px;
    padding: 12px 14px 10px 12px;
    font-size: 12.5px;
  }
  .ldai-bubble__tag {
    font-size: 10.5px;
    padding: 1px 7px;
  }
  .ldai-bubble__name {
    font-size: 10.5px;
    margin-left: 4px;
  }
  /* ボタン (× / 🔊 / 🔇) を bubble 右上にコンパクトに */
  .ldai-bubble__close { top: 4px; right: 4px; width: 22px; height: 22px; font-size: 14px; }
  .ldai-bubble__mute  { top: 4px; right: 30px; width: 22px; height: 22px; font-size: 12px; }
  .ldai-bubble__text { font-size: 12.5px; line-height: 1.55; padding-right: 4px; }
  .ldai-modal {
    left: 8px;
    right: 8px;
    bottom: 76px;
    width: auto;
    max-height: 70vh;
  }
}

/* ---------- prefers-reduced-motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .ldai-avatar,
  .ldai-avatar.is-entering,
  .ldai-avatar.is-shrunk .ldai-avatar__body,
  .ldai-glow,
  .ldai-modal,
  .ldai-banner {
    animation: none !important;
    transition: opacity 0.2s ease !important;
  }
  .ldai-avatar__eyes::before,
  .ldai-avatar__eyes::after {
    animation: none;
    opacity: 0.85;
    transform: scaleY(0.1);
  }
  /* crossfade も無効化（即時切替）して動き酔いを防ぐ */
  .ldai-avatar__frame {
    transition: none !important;
  }
  /* video モード時の瞬きオーバーレイも止める */
  .ldai-avatar__video-blink {
    animation: none !important;
    opacity: 0 !important;
  }
}
