.mate-chat {
  --chat-accent: #d9bd79;
  --chat-tint: #1e3a31;
  position: fixed;
  right: 26px;
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 45;
  color: #f3f0e7;
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', sans-serif;
}
.mate-chat [hidden] { display: none !important; }
.mate-chat button, .mate-chat textarea { font: inherit; }
.mate-chat button { cursor: pointer; }
.mate-chat button:disabled { cursor: default; opacity: .4; }
.mate-chat button:focus-visible, .mate-chat textarea:focus-visible,
.chat-messages:focus-visible { outline: 2px solid var(--chat-accent); outline-offset: 3px; }
.chat-avatar {
  width: 45px;
  height: 45px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--chat-accent) 45%, transparent);
  display: block;
  overflow: hidden;
}
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: 69% 28%; transform: scale(2.3); transform-origin: 75% 20%; }
.chat-launcher {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px 9px 9px;
  min-height: 62px;
  border-radius: 34px;
  border: 1px solid color-mix(in srgb, var(--chat-accent) 50%, transparent);
  color: #f3f0e7;
  background: linear-gradient(130deg, var(--chat-tint), #121b19);
  box-shadow: 0 8px 30px #0005;
  text-align: left;
  transition: transform .2s, border-color .2s;
}
.chat-launcher:hover { transform: translateY(-2px); border-color: var(--chat-accent); }
.chat-launcher small { display: block; color: #d0d4ca; font-size: 10px; margin-bottom: 4px; letter-spacing: .03em; }
.chat-launcher b { font-weight: 500; font-size: 14px; }
.chat-launcher svg { width: 21px; height: 21px; margin-left: 9px; stroke: var(--chat-accent); stroke-width: 1.3; fill: none; }
.chat-panel {
  width: 380px;
  height: min(570px, calc(100dvh - 120px));
  max-width: calc(100vw - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid color-mix(in srgb, var(--chat-accent) 40%, #17201d);
  border-radius: 18px;
  background: linear-gradient(155deg, color-mix(in srgb, var(--chat-tint) 66%, #111915), #111915 60%);
  box-shadow: 0 18px 60px #0008;
  animation: chat-arrive .2s ease-out;
}
.chat-heading { display: flex; align-items: center; gap: 12px; padding: 20px 18px 14px; }
.chat-identity { flex: 1; min-width: 0; }
.chat-identity p { margin: 0 0 5px; display: flex; align-items: center; gap: 8px; color: var(--chat-accent); font-size: 11px; }
.chat-identity h2 { font-family: inherit; font-size: 20px; font-weight: 500; letter-spacing: -.03em; line-height: 1.2; margin: 0; }
.chat-demo-tag { color: #c5c9c2; font-size: 9px; border: 1px solid #ffffff24; border-radius: 3px; padding: 2px 4px; }
.chat-icon-button { display: grid; place-items: center; border: 0; background: transparent; color: #d8dacf; border-radius: 50%; width: 36px; height: 36px; }
.chat-icon-button:hover { background: #ffffff10; }
.chat-icon-button svg, .chat-send svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.5; fill: none; }
.chat-location { display: flex; align-items: center; gap: 7px; margin: 0 18px; padding: 0 0 14px; border-bottom: 1px solid #ffffff14; color: #c4c9bf; font-size: 10px; }
.chat-location > :first-child { color: var(--chat-accent); }
.chat-location > :last-child { margin-left: auto; color: #9fa99d; }
.chat-messages { flex: 1; min-height: 70px; overflow-y: auto; overscroll-behavior: contain; padding: 20px 18px; scrollbar-width: thin; scrollbar-color: #ffffff32 transparent; }
.chat-message { display: flex; flex-direction: column; align-items: flex-start; margin-bottom: 17px; }
.chat-message:last-child { margin-bottom: 0; }
.chat-message-label { margin: 0 0 7px 2px; color: #b7c2b2; font-size: 10px; letter-spacing: .02em; }
.chat-bubble { margin: 0; max-width: 91%; padding: 12px 14px; border: 1px solid #ffffff12; background: #ffffff08; border-radius: 2px 12px 12px 12px; font-size: 13px; line-height: 1.75; word-break: keep-all; overflow-wrap: anywhere; white-space: pre-wrap; }
.chat-message.user { align-items: flex-end; }
.chat-message.user .chat-bubble { background: color-mix(in srgb, var(--chat-tint) 78%, #ffffff); border-color: color-mix(in srgb, var(--chat-accent) 22%, transparent); border-radius: 12px 2px 12px 12px; color: #fff; }
.chat-typing { display: flex; gap: 4px; width: fit-content; padding: 13px; border-radius: 12px; background: #ffffff08; }
.chat-typing i { width: 4px; height: 4px; border-radius: 50%; background: var(--chat-accent); animation: chat-pulse 1s infinite; }
.chat-typing i:nth-child(2) { animation-delay: .15s; }
.chat-typing i:nth-child(3) { animation-delay: .3s; }
.chat-bottom { flex-shrink: 0; border-top: 1px solid #ffffff12; padding: 12px 14px 13px; background: #1018149c; }
.chat-prompts { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-bottom: 12px; padding: 3px 2px; }
.chat-prompts::-webkit-scrollbar { display: none; }
.chat-prompts button { flex: 0 0 auto; border: 1px solid #ffffff26; border-radius: 20px; background: transparent; color: #d8decf; padding: 7px 10px; font-size: 11px; }
.chat-prompts button:hover { background: #ffffff0c; border-color: var(--chat-accent); }
.chat-form { display: flex; gap: 8px; align-items: flex-end; border: 1px solid #ffffff30; border-radius: 12px; padding: 7px; background: #ffffff05; }
.chat-form:focus-within { border-color: color-mix(in srgb, var(--chat-accent) 75%, transparent); }
.chat-form textarea { min-width: 0; width: 100%; height: 34px; max-height: 90px; border: 0; outline: 0; border-radius: 5px; resize: none; background: transparent; color: #f4f1e9; padding: 8px 5px; font-size: 13px; line-height: 18px; }
.chat-form textarea:focus-visible { outline: 0; }
.chat-form textarea::placeholder { color: #a2aca0; }
.chat-send { display: grid; place-items: center; flex: 0 0 auto; width: 34px; height: 34px; border-radius: 8px; border: 0; background: var(--chat-accent); color: #18221c; }
.chat-disclosure { color: #a3ae9e; text-align: center; font-size: 9px; line-height: 1.5; margin: 9px 0 0; }
.chat-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.mate-chat.is-quiet:not(.is-open) .chat-launcher { opacity: .6; }
@keyframes chat-arrive { from { opacity: 0; } to { opacity: 1; } }
@keyframes chat-pulse { 50% { opacity: .35; } }
@media (max-width: 700px) {
  .mate-chat { right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); }
  .chat-launcher { min-height: 54px; padding: 7px 13px 7px 7px; gap: 9px; }
  .chat-launcher .chat-avatar { width: 37px; height: 37px; }
  .chat-launcher small { display: none; }
  .chat-launcher b { font-size: 12px; }
  .mate-chat.is-open .chat-launcher { display: none; }
  .chat-panel { width: 380px; height: min(590px, calc(100dvh - 32px)); margin-bottom: 0; }
  .mate-chat.is-quiet:not(.is-open) { bottom: 100px; }
}
@media (prefers-reduced-motion: reduce) {
  .mate-chat *, .mate-chat *::before, .mate-chat *::after { animation: none !important; transition: none !important; }
}
