/* =========================
   MH Monster Dict Bot (clean full)
   Panel overlaps launcher (PC/Mobile)
   ========================= */

/* ---- 基準値（ここ触れば調整できる） ---- */
:root{
  --mhdbot-edge: 18px;            /* 画面端からの距離（右/左） */
  --mhdbot-bottom: 18px;          /* アイコンの下位置 */
  --mhdbot-launcher: 64px;        /* アイコンサイズ */

  /* パネルの横幅 */
  --mhdbot-panel-w: 420px;

  /* パネルの下端（= 画面下に寄せる）。フッターメニュー回避はモバイルで上書き */
  --mhdbot-panel-bottom: 12px;

  /* パネルの最大高さ（PC） */
  --mhdbot-panel-max: 860px;

  /* スマホのフッターメニュー回避（必要なら 0px に） */
  --mhdbot-footer-avoid: 4px;
}

/* =========================
   Floating base
   ========================= */
.mhdbot--floating{
  position: fixed;
  z-index: 2147483000;
  border: none;
  padding: 0;
  max-width: none;

  /* ランチャー（アイコン）の位置 */
  bottom: calc(var(--mhdbot-bottom) + env(safe-area-inset-bottom, 0px));
}

.mhdbot--floating.mhdbot--right{ right: var(--mhdbot-edge); }
.mhdbot--floating.mhdbot--left { left:  var(--mhdbot-edge); }

/* =========================
   Launcher (icon)
   ========================= */
.mhdbot__launcher{
  width: var(--mhdbot-launcher);
  height: var(--mhdbot-launcher);
  border-radius: 999px;

  background: url("https://burasut.com/wp-content/uploads/2026/03/dictbot.png") center/cover no-repeat;
  border: 2px solid rgba(124,58,237,.8);
  box-shadow:
    0 0 0 3px rgba(124,58,237,.25),
    0 12px 30px rgba(0,0,0,.35);

  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
  position: relative;
  z-index: 2147483002; /* パネルより前にしたいならここを上げる */
}

.mhdbot__launcher:hover{
  transform: translateY(-2px);
  box-shadow:
    0 0 0 4px rgba(124,58,237,.35),
    0 16px 40px rgba(0,0,0,.45);
}

.mhdbot__launcherText{ display:none; }

/* =========================
   Panel (fixed: bottom aligned, overlap launcher)
   ========================= */
.mhdbot__panel{
  position: fixed;
  z-index: 2147483001;

  /* 画面下に寄せて、アイコンに被ってOK */
  bottom: calc(var(--mhdbot-panel-bottom) + env(safe-area-inset-bottom, 0px));

  width: min(var(--mhdbot-panel-w), calc(100vw - (var(--mhdbot-edge) * 2)));
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(17, 24, 39, 0.90);
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 50px rgba(0,0,0,.45);
  overflow: hidden;

  /* 開閉アニメ */
  transform: translateY(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;

  /* 中身を縦flex */
  display: flex;
  flex-direction: column;

  /* できるだけ大きく */
  height: min(var(--mhdbot-panel-max), calc(92vh - 18px));
  max-height: calc(92vh - 18px);
}

.mhdbot--right .mhdbot__panel{ right: var(--mhdbot-edge); }
.mhdbot--left  .mhdbot__panel{ left:  var(--mhdbot-edge); }

.mhdbot[data-state="open"] .mhdbot__panel{
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* =========================
   Header
   ========================= */
.mhdbot__panelHeader{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 12px 14px;
  background: #0f172a;
  border-bottom: 1px solid rgba(255,255,255,.08);
  color: #f3f4f6;
}

.mhdbot__panelTitle{ font-weight:700; }

.mhdbot__close{
  width:38px;
  height:38px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.14);
  background:#1f2937;
  color:#fff;
  cursor:pointer;
  font-size: 20px;
  line-height: 38px;
  text-align:center;
}

/* =========================
   Log
   ========================= */
.mhdbot__log{
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  background: #0f172a;
}

.mhdbot__row{ display:flex; margin:8px 0; }
.mhdbot__row--user{ justify-content:flex-end; }
.mhdbot__row--bot { justify-content:flex-start; }

.mhdbot__bubble{
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 14px;
  background:#1f2937;
  border:1px solid rgba(255,255,255,.06);
  color:#f3f4f6;
  font-size:13px;
  line-height:1.5;
}
.mhdbot__row--user .mhdbot__bubble{ background:#2b3344; }

/* helpers */
.mhdbot__title{ font-weight:700; margin-bottom:6px; }
.mhdbot__small, .mhdbot__meta{ font-size:12px; color:#9ca3af; }
.mhdbot__sources{ margin-top:10px; font-size:12px; }
.mhdbot__content img{ max-width:100%; height:auto; cursor: zoom-in; }

/* =========================
   Hint
   ========================= */
.mhdbot__hint{
  padding: 8px 12px 12px;
  font-size: 12px;
  color: #9ca3af;
  background: #111827;
  border-top: 1px solid rgba(255,255,255,.08);
}

/* =========================
   Input bar
   ========================= */
.mhdbot__bar{
  display:flex;
  gap:8px;
  padding:12px;
  background:#111827;
  border-top:1px solid rgba(255,255,255,.08);
}

.mhdbot__input{
  flex:1;
  padding:10px 12px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,.1);
  background:#1f2937;
  color:#f3f4f6;
}
.mhdbot__input::placeholder{ color:#6b7280; }

.mhdbot__send{
  padding:10px 14px;
  border-radius:10px;
  border:none;
  background:#7c3aed;
  color:#fff;
  font-weight:600;
  cursor:pointer;
}
.mhdbot__send:hover{ background:#6d28d9; }

/* =========================
   Candidate buttons
   ========================= */
.mhdbot__candlist{ margin-top:8px; display:grid; gap:8px; }

.mhdbot__candBtn{
  width:100%;
  text-align:left;
  border-radius:12px;
  padding:10px 12px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.06);
  color:inherit;
  cursor:pointer;
}
.mhdbot__candBtn:hover{ background: rgba(255,255,255,.10); }

.mhdbot__candNo{ font-weight:700; margin-right:6px; }
.mhdbot__candTitle{ font-weight:600; margin-right:8px; }

/* =========================
   Weakness tables
   ========================= */
.mhdbot__tblwrap{display:flex;gap:10px;flex-wrap:wrap;margin:8px 0}
.mhdbot__tbl{border-collapse:collapse;min-width:170px;background:rgba(255,255,255,0.06)}
.mhdbot__tbl th,.mhdbot__tbl td{border:1px solid rgba(255,255,255,0.15);padding:6px 8px;font-size:13px}
.mhdbot__tbl thead th{text-align:left}
.mhdbot__legend{margin-top:6px;font-size:12px;opacity:.85}
.mhdbot__note{font-size:13px;line-height:1.5}
.mhdbot__m{display:inline-block;min-width:1.6em;text-align:center;border-radius:6px;padding:2px 6px;border:1px solid rgba(255,255,255,0.18)}
.mhdbot__m--ss{font-weight:700}
.mhdbot__m--s{font-weight:600}
.mhdbot__m--w{opacity:.9}
.mhdbot__m--n{opacity:.8}
.mhdbot__m--u{opacity:.7}

/* =========================
   Mobile tweaks (panel larger + footer avoid)
   ========================= */
@media (max-width: 768px){
  /* パネルはフッター分だけ上げる（被ってOKなら 0px にしてもOK） */
  .mhdbot__panel{
    bottom: calc(var(--mhdbot-panel-bottom) + var(--mhdbot-footer-avoid) + env(safe-area-inset-bottom, 0px));
    width: min(92vw, var(--mhdbot-panel-w));
    height: min(80vh, 720px);
    max-height: 80vh;
  }
}

@media (max-width: 480px){
  .mhdbot__panel{
    width: min(94vw, var(--mhdbot-panel-w));
  }
}

/* =========================
   Lightbox (PC/スマホ共通)
   ========================= */
.mhdbot__lightbox{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.86);
  z-index: 2147483647;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: zoom-out;
}

.mhdbot__lightboxInner{
  position: relative;
  max-width: 92vw;
  max-height: 92vh;
}

.mhdbot__lightboxInner img{
  display:block;
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 12px;
  box-shadow: 0 0 50px rgba(0,0,0,.55);
}

/* 閉じるボタン：大きく、右上に固定 */
.mhdbot__lightboxClose{
  position: absolute;
  top: -14px;
  right: -14px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(15,23,42,.9);
  color: #fff;
  font-size: 26px;
  line-height: 44px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(0,0,0,.35);
}
.mhdbot__lightboxClose:hover{ filter: brightness(1.08); }

/* ライトボックス表示中はページスクロール禁止 */
body.mhdbot--lb-open{
  overflow: hidden !important;
  touch-action: none;
  transform: none !important;
}

/* =========================
   FIX 1) Mobile footer menu overlap
   - フッターメニューに被らないように「アイコンもパネルも」上げる
   ========================= */

:root{
  /* フッターメニューの高さに合わせて調整（70〜110あたり） */
  --mhdbot-footer-avoid: 26px;
}

@media (max-width: 768px){
  /* ランチャー（アイコン）も上げる：フッターアイコンと干渉しない */
  .mhdbot--floating{
    bottom: calc(var(--mhdbot-bottom) + var(--mhdbot-footer-avoid) + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* パネルも同じ分だけ上げる（下端の入力欄がフッターに食われない） */
  .mhdbot__panel{
    bottom: calc(var(--mhdbot-panel-bottom) + var(--mhdbot-footer-avoid) + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* =========================
   FIX 2) PC header/logo overlap
   - 辞書をヘッダーより前面に出す（ロゴを後ろに回す）
   ========================= */

/* 辞書側を最強レイヤーへ */
.mhdbot--floating{ z-index: 2147483646 !important; }
.mhdbot__panel{ z-index: 2147483647 !important; }

/* ついで：ランチャーも前面にしたい場合 */
.mhdbot__launcher{ z-index: 2147483647 !important; }