/* ====== Base ====== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif; margin: 0; }
/* body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif; margin: 0; background:#f5f5f5; } */
/* ====== Right-bottom launcher button ====== */
.chat-toggle-button {
  position: fixed; bottom: 20px; right: 0;
  background: none; border: none; width: 300px; height: auto; padding: 0;
  cursor: pointer; z-index: 1000; transition: transform .3s ease;
}
.chat-toggle-button img { width: 100%; height: auto; display: block; }
.chat-toggle-button:hover { transform: scale(1.05); }
@media (max-width: 768px) { .chat-toggle-button { width: 200px; } }

/* ====== Chat panel ====== */
.chat-wrapper {
  max-width: 40%; width: 100vw; height: 95dvh; border-radius: 10px; overflow: hidden; border: 1px solid #ccc; background: #fff;
  position: fixed; bottom: 0; right: 0; box-shadow: 0 0 10px rgba(0,0,0,.3);
  display: none; flex-direction: column; opacity: 0; transform: translateY(30px); pointer-events: none; transition: opacity .4s ease, transform .4s ease; z-index: 99999;font-size: 15px;line-height: 1.5;
}
.chat-wrapper.open { display: flex; opacity: 1; transform: translateY(0); pointer-events: auto; }
@media (max-width: 560px){
  .chat-wrapper { max-width: 100%; height: 100dvh; }
}

.chat-header {
  background: #2a8f7a; color: #fff; padding: 10px; font-weight: bold; font-size: 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.chat-header span { color: #dfffd4; display: block; font-size: 12px; }
.chat-header .close-btn { background: none; border: none; color: #fff; font-size: 35px; cursor: pointer; }

.chat-body { padding: 15px; flex: 1; overflow-y: auto; }

.msg { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.msg.user { justify-content: flex-end; }
.msg .bubble {
  margin-top: 1.5vw; padding: 10px; border-radius: 12px; background: #e0f4ee; max-width: 80%;
  white-space: pre-line; word-break: break-word; overflow-wrap: break-word;
}
.msg.user .bubble { background: #cde6dd; }
.msg > img.avatar { width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto; }

.chat-suggestions { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; max-height: 200px; overflow-y: auto; }
.chat-suggestions button { background: #fff; border: 2px solid #c7b386; border-radius: 8px; padding: 10px; text-align: left; font-weight: bold; cursor: pointer; }

.chat-footer { padding: 10px; background: #e3eeee; display: flex; flex-direction: column; gap: 8px; }
.footer-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.footer-buttons button { background: #2a8f7a; color: #fff; border: none; border-radius: 15px; padding: 6px 14px; font-weight: bold; cursor: pointer; }
.input-group { display: flex; gap: 5px; }
.input-group input { flex: 1; padding: 10px; border: 1px solid #ccc; border-radius: 6px; }
.input-group button { background: #2a8f7a; color: #fff; border: none; padding: 0 16px; border-radius: 6px; }
.chat-note { font-size: 11px; color: gray; margin-top: 4px; }

/* Typewriter */
.loading-dots::after { content: '...'; animation: dots 1.2s steps(3,end) infinite; }
@keyframes dots { 0%{content:''} 33%{content:'.'} 66%{content:'..'} 100%{content:'...'} }
.fade-char { opacity: 0; display: inline; animation: charFade .48s ease forwards; }
@keyframes charFade { from{opacity:0; transform: translateY(.2em);} to{opacity:1; transform: translateY(0);} }

/* Inline media inside bubble */
.rel__noreferrer__link { display:inline-block; word-break: break-word; overflow-wrap: break-word; max-width:100%; text-decoration: underline; color:#007bff; }
.msg .bubble img.chat-media, .msg .bubble video.chat-media {
  display:block; max-width:100%; height:auto; margin:10px 0 0; border-radius:6px;
}
@media (min-width: 769px) {
  .msg .bubble img.chat-media, .msg .bubble video.chat-media { width: 300px; max-width:100%; }
}

/* ====== Popup (centered) ====== */
.dspp-overlay{
  position:fixed; inset:0; background:rgba(0,0,0,.55);
  display:none; opacity:0; transition:opacity .25s ease; z-index:9998;
}
.dspp-overlay.show{ display:block; opacity:1; }

.dspp-popup{
  position: fixed; left: 50%; top: 50%; z-index: 9999;
  width: min(92vw, 420px); max-height: calc(100vh - 48px);
  border-radius: 16px; overflow: hidden; box-shadow: 0 16px 40px rgba(0,0,0,.5);
  transform: translate(-50%, calc(-50% + 16px)); opacity: 0; display: none;
  transition: transform .25s ease, opacity .25s ease;
  background: #111; cursor: pointer; /* 全体クリックでチャット起動 */
}
.dspp-popup.show{ display:block; transform: translate(-50%, -50%); opacity:1; }
.dspp-img{ display:block; width:100%; height:auto; }
.dspp-close{
  position:absolute; top:8px; right:8px; width:36px; height:36px;
  border-radius:999px; border:1px solid rgba(255,255,255,.3);
  background:rgba(0,0,0,.35); color:#fff; display:grid; place-items:center; cursor:pointer;
}
@media (max-width:560px){
  .dspp-popup{ width: calc(100vw - 24px); max-height: calc(100vh - 24px); }
}