/* ============================================================
   Misaki Ukagaka - ニャン原ミサキ（サイト常駐伺か）スタイル
   ------------------------------------------------------------
   ・PC   : 右下に立ち絵常駐（デスクトップ版の125%相当）＋伺かバルーン
   ・スマホ: 右下の呼び出しボタン → 下部パネルがスライドイン
   ・吹き出しはSSPバルーンをリカラーした image/misaki/balloon.png（水色）
   ============================================================ */

#misaki-root {
  position: fixed;
  right: 0;
  bottom: 0;
  z-index: 800; /* サイト本体より前・入口演出(9000台)より後ろ */
  font-family: "MS Gothic", "ＭＳ ゴシック", "MS UI Gothic", monospace;
  line-height: 1.55;
  pointer-events: none; /* 土台は透過。子の操作部だけ受ける */
}

#misaki-root *,
.misaki-panel * {
  box-sizing: border-box;
}

/* ============ PC: 立ち絵（125%＝480x720相当。画面が低い時は縮む） ============ */
.misaki-figure {
  position: relative;
  display: block;
  margin: 0 4px -4px 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  filter: drop-shadow(2px 4px 6px rgba(0, 0, 0, 0.55));
  transform: translateY(20px);
}

.misaki-figure img {
  display: block;
  height: min(720px, 78vh);
  width: auto;
  image-rendering: auto;
}

/* ============ 吹き出し（SSPバルーン流用・水色） ============ */
.misaki-balloon {
  position: absolute;
  right: min(400px, 30vw);
  bottom: min(430px, 46vh);
  width: 340px;
  max-width: 62vw;
  min-height: 140px;
  padding: 10px 16px 12px 14px;
  pointer-events: auto;
  color: #10222e;
  background: url("../image/misaki/balloon.png");
  background-size: 100% 100%;
  filter: drop-shadow(3px 3px 3px rgba(0, 0, 0, 0.4));
}

.misaki-balloon[hidden] {
  display: none;
}

/* しっぽは balloon.png（SSPバルーン）に内蔵されているのでCSSでは描かない */

.misaki-balloon-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
  color: #2a5a7a;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 1px;
}

.misaki-balloon-title .misaki-x {
  padding: 0 5px;
  margin: 0;
  border: 1px solid #3a6080;
  color: #2a5a7a;
  background: transparent;
  font-size: 10px;
  line-height: 1.3;
  cursor: pointer;
}

.misaki-balloon-body {
  min-height: 4.6em;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ============ 選択肢メニュー（伺か風の青リンク） ============ */
.misaki-menu-lead {
  margin: 0 0 6px;
}

/* APIキー設定などの注意書き */
.misaki-note {
  margin: 0 0 6px;
  font-size: 11px;
  line-height: 1.45;
  color: #2a5a7a;
}

.misaki-menu {
  display: block;
}

.misaki-menu button {
  display: block;
  width: 100%;
  padding: 2px 2px 2px 14px;
  margin: 0 0 2px;
  border: 0;
  background: transparent;
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  color: #0645ad;
  text-decoration: underline;
  cursor: pointer;
}

.misaki-menu button:hover,
.misaki-menu button:focus {
  color: #d0006a;
  background: rgba(255, 255, 255, 0.45);
}

/* ============ フリーワード入力 ============ */
.misaki-input {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.misaki-input input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 3px 6px;
  font-family: inherit;
  font-size: 13px;
  color: #10222e;
  background: #ffffff;
  border-top: 2px solid #7a8a9a;
  border-left: 2px solid #7a8a9a;
  border-right: 2px solid #ffffff;
  border-bottom: 2px solid #ffffff;
}

.misaki-input button {
  flex: 0 0 auto;
  padding: 2px 12px;
  font-family: inherit;
  font-size: 12px;
  color: #10222e;
  background: #cdeeff;
  border: 1px solid #3a6080;
  cursor: pointer;
}

.misaki-input button:active {
  background: #a8d8f0;
}

/* ============ 操作ボタン列 ============ */
.misaki-controls {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  padding: 4px 2px 2px;
}

.misaki-controls button {
  padding: 2px 8px;
  font-size: 11px;
  font-family: inherit;
  color: #10222e;
  background: #cdeeff;
  border-top: 2px solid #eaf8ff;
  border-left: 2px solid #eaf8ff;
  border-right: 2px solid #3a6080;
  border-bottom: 2px solid #3a6080;
  cursor: pointer;
}

.misaki-controls button:active {
  border-top-color: #3a6080;
  border-left-color: #3a6080;
  border-right-color: #eaf8ff;
  border-bottom-color: #eaf8ff;
}

/* ============ 最小化タブ / 復帰タブ ============ */
.misaki-tab {
  position: fixed;
  right: 8px;
  bottom: 0;
  z-index: 800;
  padding: 3px 14px 2px;
  font-size: 11px;
  font-weight: bold;
  font-family: "MS Gothic", "ＭＳ ゴシック", monospace;
  color: #10222e;
  background: #cdeeff;
  border: 2px solid #3a6080;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 0 8px rgba(65, 231, 255, 0.35);
}

.misaki-tab[hidden] {
  display: none;
}

/* ============ スマホ: 呼び出しボタン ============ */
.misaki-call {
  position: fixed;
  right: 10px;
  bottom: 12px;
  z-index: 800;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 2px solid #41e7ff;
  border-radius: 50%;
  background: #001b3f;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 0 10px rgba(65, 231, 255, 0.5), 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.misaki-call img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.misaki-call[hidden] {
  display: none;
}

/* ============ スマホ: 下部パネル ============ */
.misaki-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 810;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 8px 10px 10px;
  pointer-events: auto;
  font-family: "MS Gothic", "ＭＳ ゴシック", "MS UI Gothic", monospace;
  line-height: 1.55;
  background: linear-gradient(180deg, rgba(4, 10, 40, 0.96), rgba(0, 8, 28, 0.98));
  border-top: 2px solid #41e7ff;
  box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.6);
  transform: translateY(105%);
  transition: transform 0.28s ease;
}

.misaki-panel.is-open {
  transform: translateY(0);
}

.misaki-panel .misaki-figure {
  flex: 0 0 auto;
  margin: 0;
}

.misaki-panel .misaki-figure img {
  height: 180px;
  width: auto;
}

.misaki-panel-main {
  flex: 1 1 auto;
  min-width: 0;
}

.misaki-panel .misaki-balloon {
  position: static;
  width: 100%;
  max-width: none;
  min-height: 96px;
  margin-bottom: 6px;
}

.misaki-panel .misaki-balloon::after {
  display: none;
}

/* ============ 表示モード制御 ============ */
@media (min-width: 769px) {
  .misaki-call,
  .misaki-panel {
    display: none !important;
  }
}

@media (max-width: 768px) {
  #misaki-root {
    display: none !important;
  }

  .misaki-tab {
    display: none !important;
  }
}

/* ============ アニメーション控えめ ============ */
@media (prefers-reduced-motion: reduce) {
  .misaki-panel {
    transition: none;
  }
}
