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

/* 起動ボタン */
#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: 360px; max-width: calc(100vw - 36px);
  height: 480px; max-height: min(70vh, 560px);
  display: flex; flex-direction: column;
  background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: 0 14px 44px rgba(0, 0, 0, .26);
  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: 8px;
  padding: 12px 14px; background: var(--ncchat, #e21d7a); color: #fff;
}
.ncchat-head-dot { width: 9px; height: 9px; border-radius: 50%; background: #6dff9e; box-shadow: 0 0 0 3px rgba(255, 255, 255, .25); }
.ncchat-head-name { font-weight: 700; font-size: 14.5px; }
.ncchat-close {
  margin-left: auto; width: 30px; height: 30px; border: none; border-radius: 50%;
  background: rgba(255, 255, 255, .18); color: #fff; font-size: 19px; line-height: 1; cursor: pointer;
}
.ncchat-close:hover { background: rgba(255, 255, 255, .3); }

.ncchat-msgs { flex: 1 1 auto; overflow-y: auto; padding: 14px 12px; background: #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: #333; border: 1px solid #e8e3e8; 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: flex-end; 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 {
  margin-left: auto; display: inline-flex; align-items: center; gap: 4px;
  border: none; border-radius: 999px; padding: 5px 11px; cursor: pointer;
  background: rgba(255, 255, 255, .18); color: #fff; font-size: 11.5px; font-weight: 700; font-family: inherit;
}
.ncchat-mic:hover { background: rgba(255, 255, 255, .3); }
.ncchat-mic.is-on { background: #fff; color: var(--ncchat, #e21d7a); animation: ncchat-pulse 1.6s infinite; }
@keyframes ncchat-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,255,255,.5); } 50% { box-shadow: 0 0 0 6px rgba(255,255,255,0); } }
.ncchat-mic + .ncchat-close { margin-left: 8px; }
