/* NextCode CMS - AIチャットウィジェット */
#ncchat { position: fixed; right: 18px; bottom: 18px; z-index: 99990; font-family: inherit; }

/* ============================================================
   テーマ側の全体リセット「*{ border-radius:0 !important }」で
   ウィジェットの角が四角く潰れるのを防ぐ。#ncchat スコープ＋!important で角丸を維持。
   （テーマは .bk-ai-root 配下のみ除外しているが、AdminChat(#ncchat)は対象外のため自前で打ち消す）
   ============================================================ */
#ncchat-panel { border-radius: 22px !important; }
#ncchat-input { border-radius: 14px !important; }
#ncchat-send, #ncchat #ncchat-launcher:not(.has-ava) { border-radius: 50% !important; }
#ncchat .ncchat-mic, #ncchat .ncchat-head-ava, #ncchat .ncchat-head-dot,
#ncchat .ncchat-vstat .dot, #ncchat .ncchat-typing i { border-radius: 50% !important; }
#ncchat .ncchat-side, #ncchat .ncchat-lang { border-radius: 999px !important; }
#ncchat .ncchat-callout, #ncchat .ncchat-act, #ncchat .ncchat-area { border-radius: 16px !important; }
#ncchat .ncchat-bubble { border-radius: 16px !important; }
#ncchat .ncchat-row-bot .ncchat-bubble { border-bottom-left-radius: 5px !important; }
#ncchat .ncchat-row-user .ncchat-bubble { border-bottom-right-radius: 5px !important; }
#ncchat .ncchat-chip { border-radius: 16px !important; }
#ncchat .ncchat-langpop { border-radius: 14px !important; }
#ncchat .ncchat-langitem { border-radius: 9px !important; }
#ncchat .ncchat-area-btn { border-radius: 12px !important; }
#ncchat .ncchat-fwave { border-radius: 22px !important; }
#ncchat .ncchat-wave i { border-radius: 4px !important; }

/* 起動ボタン */
#ncchat-launcher {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--ncchat, #e21d7a); color: #fff; border: none; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .22);
  transition: transform .15s ease, box-shadow .15s ease;
}
#ncchat-launcher:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(0, 0, 0, .26); }
#ncchat-launcher:active { transform: scale(.94); }
.ncchat-launcher-txt { font-size: 10px; font-weight: 700; letter-spacing: .05em; }

/* パネル */
/* ID指定の display:flex が UA の [hidden]{display:none} より強く効いてしまい、
   JSが hidden=true にしても閉じない不具合を防ぐ（同specificityのID指定で明示的に打ち消す）。 */
#ncchat-panel[hidden] { display: none; }
#ncchat-panel {
  position: absolute; right: 0; bottom: 72px;
  width: 374px; max-width: calc(100vw - 28px);
  height: 520px; max-height: min(74vh, 580px);
  display: flex; flex-direction: column;
  background: #fff; border-radius: 22px; overflow: hidden;
  box-shadow: 0 20px 56px rgba(0, 0, 0, .3);
  animation: ncchat-in .22s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes ncchat-in { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { #ncchat-panel { animation: none; } }

.ncchat-head {
  display: flex; align-items: center; gap: 9px;
  padding: 12px 14px; color: #fff;
  background: var(--ncchat, #e21d7a);
  background: linear-gradient(135deg, var(--ncchat, #e21d7a), var(--ncchat-dk, #b80049));
}
.ncchat-head-dot { width: 9px; height: 9px; border-radius: 50%; background: #6dff9e; box-shadow: 0 0 0 3px rgba(255, 255, 255, .25); flex: 0 0 auto; }
.ncchat-head-tx { display: flex; flex-direction: column; min-width: 0; margin-right: auto; }
.ncchat-head-name { font-weight: 800; font-size: 15px; line-height: 1.2; text-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.ncchat-head-sub { font-size: 11px; opacity: .95; line-height: 1.3; margin-top: 1px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
/* ヘッダーのアイコンは素の白グリフ（背景なし）。pillはJPNだけ＝スマホ君式のすっきりヘッダー */
.ncchat-reset, .ncchat-close {
  flex: 0 0 auto; width: 30px; height: 32px; border: none; border-radius: 0;
  background: none; color: #fff; line-height: 1; cursor: pointer; opacity: .9;
}
.ncchat-reset { font-size: 19px; }
.ncchat-close { font-size: 22px; }
.ncchat-reset:hover, .ncchat-close:hover { opacity: 1; }
.ncchat-reset:active, .ncchat-close:active { transform: scale(.9); }

/* 音声ステータス（通話中バナー） */
.ncchat-vstat { display: none; text-align: center; font-size: 12.5px; font-weight: 800; color: var(--ncchat, #e21d7a); background: #f5f9f9; padding: 8px 6px; }
.ncchat-vstat.live { display: block; }
.ncchat-vstat .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #ff3b3b; margin-right: 7px; vertical-align: middle; animation: ncchat-blink 1s infinite; }
@keyframes ncchat-blink { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

.ncchat-msgs { flex: 1 1 auto; overflow-y: auto; padding: 14px 12px; background: var(--ncchat-lt, #f7f6f8); }
.ncchat-row { display: flex; margin: 0 0 10px; }
.ncchat-row-user { justify-content: flex-end; }
.ncchat-bubble {
  max-width: 82%; padding: 9px 13px; border-radius: 14px;
  font-size: 14px; line-height: 1.65; white-space: pre-wrap; word-break: break-word;
}
.ncchat-row-bot .ncchat-bubble { background: #fff; color: #222; border: 1px solid rgba(14, 140, 134, .1); box-shadow: 0 1px 3px rgba(0, 0, 0, .07); border-bottom-left-radius: 4px; }
.ncchat-row-user .ncchat-bubble { background: var(--ncchat, #e21d7a); color: #fff; border-bottom-right-radius: 4px; }
.ncchat-row-err .ncchat-bubble { background: #fff4f4; color: #b54343; border: 1px solid #f3c1c1; font-size: 13px; }

.ncchat-typing { display: inline-flex; gap: 4px; padding: 3px 2px; }
.ncchat-typing i { width: 7px; height: 7px; border-radius: 50%; background: #c9bfc9; animation: ncchat-blink 1.2s infinite; }
.ncchat-typing i:nth-child(2) { animation-delay: .2s; }
.ncchat-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes ncchat-blink { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.ncchat-inputrow { display: flex; align-items: center; gap: 8px; padding: 10px; background: #fff; border-top: 1px solid #eee; }
#ncchat-input {
  flex: 1 1 auto; resize: none; border: 2px solid #e4dde4; border-radius: 12px;
  padding: 9px 12px; font-size: 16px; line-height: 1.5; font-family: inherit; max-height: 96px;
  background: #fff; color: #333;
}
#ncchat-input:focus { outline: none; border-color: var(--ncchat, #e21d7a); }
#ncchat-send {
  flex: 0 0 auto; width: 42px; height: 42px; border: none; border-radius: 50%;
  background: var(--ncchat, #e21d7a); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s ease;
}
#ncchat-send:active { transform: scale(.92); }
#ncchat-send:disabled { background: #cdbac6; cursor: default; }

.ncchat-foot { text-align: center; font-size: 10px; color: #b5a9b1; padding: 4px 0 7px; background: #fff; }

/* モバイル: 下からのシート風 */
@media (max-width: 599px) {
  #ncchat { right: 14px; bottom: 14px; }
  #ncchat-panel {
    position: fixed; left: 10px; right: 10px; bottom: 84px;
    width: auto; height: 64vh; max-height: none;
  }
}

/* 音声チャット: 入力欄の「話す」ボタン（大きめ・押すと通話開始） */
.ncchat-mic {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--ncchat, #e21d7a); background: #fff; color: var(--ncchat, #e21d7a);
  transition: transform .1s ease;
}
.ncchat-mic:active { transform: scale(.92); }
.ncchat-mic.live { background: var(--ncchat, #e21d7a); color: #fff; border-color: var(--ncchat, #e21d7a); animation: ncchat-pulse 1.4s infinite; }
@keyframes ncchat-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,59,59,.5); } 60% { box-shadow: 0 0 0 10px rgba(255,59,59,0); } }

/* 通話中の波形（テキスト入力の代わりに表示） */
.ncchat-inputrow.live #ncchat-input, .ncchat-inputrow.live #ncchat-send { display: none; }
.ncchat-fwave { display: none; flex: 1; align-items: center; justify-content: center; gap: 12px; min-height: 44px;
  background: #f5f9f9; border: 2px solid rgba(14, 80, 80, .15); border-radius: 22px; padding: 6px 16px; }
.ncchat-inputrow.live .ncchat-fwave { display: flex; }
.ncchat-wave { display: inline-flex; align-items: center; gap: 4px; height: 30px; }
.ncchat-wave i { display: block; width: 4px; height: 30px; border-radius: 4px; background: var(--ncchat, #e21d7a);
  transform: scaleY(.2); transform-origin: center; animation: ncchat-wv 1s ease-in-out infinite; }
.ncchat-wave i:nth-child(2){animation-delay:.10s} .ncchat-wave i:nth-child(3){animation-delay:.20s} .ncchat-wave i:nth-child(4){animation-delay:.30s}
.ncchat-wave i:nth-child(5){animation-delay:.15s} .ncchat-wave i:nth-child(6){animation-delay:.25s} .ncchat-wave i:nth-child(7){animation-delay:.05s}
.ncchat-wave i:nth-child(8){animation-delay:.35s} .ncchat-wave i:nth-child(9){animation-delay:.20s} .ncchat-wave i:nth-child(10){animation-delay:.10s} .ncchat-wave i:nth-child(11){animation-delay:.30s}
@keyframes ncchat-wv { 0%,100% { transform: scaleY(.2); } 50% { transform: scaleY(1); } }
.ncchat-fwt { font-size: 13.5px; font-weight: 800; color: var(--ncchat, #e21d7a); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .ncchat-wave i { animation: none; transform: scaleY(.6); } }

/* ============================================================
   キャラクター起動ランチャー（スマホ君風・大きな立ちキャラ＋吹き出し＋左右切替）
   window.NC_CHAT.avatarFull に立ちキャラ画像がある時だけ有効
   ============================================================ */
#ncchat.has-ava { right: 20px; bottom: 20px; left: auto; }
#ncchat.has-ava.pos-left { left: 20px; right: auto; }
#ncchat.has-ava #ncchat-launcher {
  position: static; width: auto; height: auto; border-radius: 0;
  background: none; border: none; box-shadow: none; padding: 0;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  animation: ncchat-float 3.6s ease-in-out infinite;
}
#ncchat.has-ava.pos-left #ncchat-launcher { align-items: flex-start; }
#ncchat.has-ava #ncchat-launcher:active { transform: scale(.95); }
@keyframes ncchat-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@media (prefers-reduced-motion: reduce) { #ncchat.has-ava #ncchat-launcher { animation: none; } }

/* 左右切替ボタン(⇄) */
.ncchat-side {
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; color: var(--ncchat, #0E8C86); border: 2px solid var(--ncchat, #0E8C86);
  border-radius: 999px; font-size: 13px; font-weight: 900; padding: 3px 11px; line-height: 1;
  cursor: pointer; box-shadow: 0 3px 10px rgba(14, 80, 80, .22); font-family: inherit;
  -webkit-tap-highlight-color: transparent; white-space: nowrap;
}
.ncchat-side:active { transform: scale(.92); }

/* 吹き出し（○○に聞く / タップで相談） */
.ncchat-callout {
  position: relative; background: #fff; color: var(--ncchat, #0E8C86);
  font-weight: 800; font-size: 15px; line-height: 1.2; padding: 10px 15px; border-radius: 16px;
  box-shadow: 0 6px 18px rgba(14, 80, 80, .26); white-space: nowrap; margin-right: 6px;
  border: 2px solid var(--ncchat, #0E8C86);
}
.ncchat-callout small { display: block; font-size: 10.5px; font-weight: 700; color: var(--ncchat, #0E8C86); margin-top: 2px; opacity: .92; }
.ncchat-callout:after {
  content: ""; position: absolute; right: 26px; bottom: -9px; width: 16px; height: 16px; background: #fff;
  border-right: 2px solid var(--ncchat, #0E8C86); border-bottom: 2px solid var(--ncchat, #0E8C86); transform: rotate(45deg);
}
#ncchat.has-ava.pos-left .ncchat-callout { margin-left: 6px; margin-right: 0; }
#ncchat.has-ava.pos-left .ncchat-callout:after { left: 26px; right: auto; }
#ncchat.has-ava.is-open .ncchat-callout, #ncchat.has-ava.is-open .ncchat-side { display: none; }

/* 大きな立ちキャラ */
.ncchat-kun {
  height: 180px; width: auto; display: block; pointer-events: none;
  filter: drop-shadow(0 9px 14px rgba(14, 80, 80, .32));
  -webkit-filter: drop-shadow(0 9px 14px rgba(14, 80, 80, .32));
}
@media (max-width: 600px) { .ncchat-kun { height: 148px; } .ncchat-callout { font-size: 13px; padding: 8px 12px; } }
@media (max-width: 380px) { .ncchat-kun { height: 124px; } .ncchat-callout { display: none; } .ncchat-side { display: none; } }

/* ヘッダー／吹き出し横は「丸い顔」アバター（立ちキャラを上寄せクロップして顔を見せる） */
.ncchat-head-ava {
  width: 42px; height: 42px; border-radius: 50%; object-fit: cover; object-position: center 16%;
  border: 2px solid rgba(255, 255, 255, .6); background: #fff; flex: 0 0 auto;
}
.ncchat-head .ncchat-head-name { font-size: 15px; }
.ncchat-row-bot { align-items: flex-end; gap: 7px; }
.ncchat-row-ava {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover; object-position: center 16%; flex: 0 0 auto;
  background: #fff; border: 1.5px solid #e8e3e8; align-self: flex-end;
}
.ncchat-row-bot .ncchat-bubble { border-bottom-left-radius: 4px; }

/* ============================================================
   スマホ君式フル機能の追加コンポーネント
   （多言語ピッカー / クイックchip / 即アクション / 対応エリアカード / 電話リンク）
   ============================================================ */

/* 本文内の電話番号リンク（タップで発信） */
.ncchat-bubble a { color: var(--ncchat, #0E8C86); font-weight: 700; }
.ncchat-row-user .ncchat-bubble a { color: #fff; text-decoration: underline; }
.ncchat-tel { font-weight: 800; text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }

/* 言語ピッカー（ヘッダーの🌐ボタン＋ポップアップ） */
.ncchat-lang {
  flex: 0 0 auto; margin-left: 2px; background: rgba(255, 255, 255, .22);
  border: 1px solid rgba(255, 255, 255, .55); color: #fff; font-size: 12px; font-weight: 800;
  cursor: pointer; line-height: 1; padding: 6px 9px; border-radius: 999px; white-space: nowrap; font-family: inherit;
}
.ncchat-lang:active { transform: scale(.95); }
.ncchat-langpop {
  position: absolute; top: 54px; right: 14px; background: #fff; border: 1px solid #e2e8e7;
  border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); padding: 6px; z-index: 20;
  max-height: 340px; overflow-y: auto; min-width: 172px;
}
.ncchat-langpop[hidden] { display: none; }
.ncchat-langitem {
  display: flex; align-items: center; gap: 9px; width: 100%; background: none; border: none;
  padding: 9px 10px; border-radius: 9px; cursor: pointer; text-align: left; font-family: inherit;
}
.ncchat-langitem:hover { background: #f0f7f6; }
.ncchat-langitem.on { background: #e3f2f0; }
.ncchat-langitem .fl { font-size: 19px; line-height: 1; }
.ncchat-langitem .ab { font-weight: 800; color: var(--ncchat, #0E8C86); font-size: 13px; width: 32px; }
.ncchat-langitem .nm { color: #555; font-size: 13px; }

/* クイックchip（入力欄の上・ワンタップで質問/アクション） */
.ncchat-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px; background: var(--ncchat-lt, #f7f6f8); }
.ncchat-chip {
  background: #fff; border: 1px solid #d9e6e5; color: var(--ncchat, #0E8C86);
  font-size: 12px; font-weight: 700; padding: 7px 11px; border-radius: 14px; cursor: pointer;
  white-space: nowrap; font-family: inherit; line-height: 1.2;
}
.ncchat-chip:active { transform: scale(.96); }
.ncchat-chip-reset { color: #8a8a8a; border-color: #e3e3e3; }

/* 即アクションボタン（予約/エリア/電話） */
.ncchat-acts { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 6px; padding: 0 2px; }
.ncchat-act {
  display: inline-flex; align-items: center; gap: 4px; background: var(--ncchat, #0E8C86);
  color: #fff; font-size: 13px; font-weight: 800; padding: 9px 14px; border: none; border-radius: 16px;
  cursor: pointer; text-decoration: none; box-shadow: 0 2px 8px rgba(14, 80, 80, .25); font-family: inherit;
}
.ncchat-act:active { transform: scale(.97); }

/* 対応エリアカード */
.ncchat-area {
  background: #fff; border: 2px solid #d9e6e5; border-radius: 16px; padding: 12px;
  width: 100%; max-width: 300px; box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}
.ncchat-area-h { font-weight: 800; font-size: 14px; color: var(--ncchat, #0E8C86); margin-bottom: 4px; }
.ncchat-area-ad { font-size: 12.5px; color: #555; line-height: 1.55; }
.ncchat-area-in { font-size: 12.5px; color: #159a4d; font-weight: 800; margin-top: 6px; }
.ncchat-area-btns { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.ncchat-area-btn {
  flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  background: #fff; border: 1.5px solid var(--ncchat, #0E8C86); color: var(--ncchat, #0E8C86);
  font-size: 12.5px; font-weight: 800; padding: 9px 10px; border-radius: 12px; cursor: pointer;
  text-decoration: none; white-space: nowrap; font-family: inherit;
}
.ncchat-area-btn.primary { background: var(--ncchat, #0E8C86); color: #fff; }
.ncchat-area-btn:active { transform: scale(.97); }

/* ============================================================
   モバイル: 固定ボトムメニュー（.tm-fixbar 等 = CSS変数 --s119-fixbar-h）がある
   サイトでは、起動キャラがフッターに被らないようその上に持ち上げる。
   変数未定義のサイトは 0px にフォールバック＝従来位置のまま。
   末尾配置＋同詳細度(1,1,0)で widget.css 内の #ncchat.has-ava{bottom:20px} に勝つ。
   ============================================================ */
@media (max-width: 991px) {
  #ncchat.has-ava {
    bottom: calc(var(--s119-fixbar-h, 0px) + env(safe-area-inset-bottom, 0px) + 14px);
  }
  #ncchat.has-ava.is-open #ncchat-panel {
    bottom: calc(var(--s119-fixbar-h, 0px) + env(safe-area-inset-bottom, 0px) + 14px);
  }
}
