/* 문의 챗봇 위젯 — 오른쪽 아래 버튼 → 둥근 패널(홈 · 대화 목록 · 대화). 휴대폰은 전체 화면 */
.chat { --chat-r: 24px; --chat-soft: #f2f3f0; }

/* 문의하기 버튼 — 열리면 ✕ */
.chat__fab { position: fixed; right: 20px; bottom: 20px; z-index: 60; width: 72px; height: 72px; border: 0; border-radius: 22px; padding: 0;
  background: var(--accent); color: #fff; font: inherit; font-weight: 700; font-size: .78rem; box-shadow: 0 8px 24px rgba(0,40,0,.25); cursor: pointer;
  transition: transform .15s ease, background .15s ease; }
.chat__fab:hover { background: var(--accent-strong); transform: translateY(-2px); }
.chat__fab-open, .chat__fab-close { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 100%; }
.chat__fab-close, .chat__fab[aria-expanded="true"] .chat__fab-open { display: none; }
.chat__fab[aria-expanded="true"] .chat__fab-close { display: flex; }
.chat__fab[aria-expanded="true"] { background: #fff; color: var(--ink); box-shadow: 0 8px 24px rgba(0,0,0,.15); }
.chat__fab--new::after { content: ""; position: absolute; top: 8px; right: 8px; width: 12px; height: 12px; border-radius: 50%; background: #e5484d; border: 2px solid #fff; }

/* 패널 */
.chat__panel { position: fixed; right: 20px; bottom: 106px; z-index: 61; width: 384px; height: min(640px, calc(100vh - 130px));
  display: flex; flex-direction: column; background: var(--chat-soft); border-radius: var(--chat-r); box-shadow: 0 16px 48px rgba(0,0,0,.18); overflow: hidden; }
.chat__panel[hidden] { display: none; }
.chat__close { position: absolute; top: 12px; right: 12px; z-index: 3; width: 34px; height: 34px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: rgba(0,0,0,.05); color: var(--ink); cursor: pointer; }
.chat__close:hover { background: rgba(0,0,0,.1); }
.chat__body { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.chat__scroll { flex: 1; overflow-y: auto; padding: 22px 16px 16px; display: flex; flex-direction: column; gap: 12px; }

/* 아바타 */
.chat__avatar { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 12px; background: var(--accent); display: grid; place-items: center; overflow: hidden;
  color: #fff; font-size: .8rem; font-weight: 700; }
.chat__avatar img { width: 30px; height: auto; }
.chat__avatar--staff { background: #2f6f3a; border-radius: 50%; }

/* 홈 */
.chat__home { background: linear-gradient(180deg, var(--accent-soft) 0, var(--chat-soft) 180px); }
.chat__brand { display: flex; align-items: center; gap: 10px; padding: 18px 4px 8px; }
.chat__brand-logo { width: 46px; height: auto; }
.chat__brand h2 { margin: 0; font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; }
.chat__card { background: var(--card); border-radius: 20px; padding: 18px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.chat__card--flush { padding: 8px 6px; }
.chat__card-head { display: flex; justify-content: space-between; padding: 8px 12px 4px; font-size: .82rem; color: var(--ink-muted); font-weight: 600; }
.chat__card-head a { color: var(--accent); text-decoration: none; }
.chat__who-row { display: flex; gap: 10px; align-items: center; }
.chat__who-row small { display: block; font-size: .78rem; color: var(--ink-muted); }
.chat__who-row strong { font-size: 1rem; }
.chat__greet { margin: 12px 0 16px 46px; font-size: .92rem; line-height: 1.6; color: #333; }
.chat__cta { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 14px; border-radius: 999px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 1rem; text-decoration: none; transition: background .15s; }
.chat__cta:hover { background: var(--accent-strong); text-decoration: none; }
.chat__cta--float { position: absolute; left: 50%; bottom: 76px; transform: translateX(-50%); width: auto; padding: 12px 22px; box-shadow: 0 8px 20px rgba(0,60,0,.25); }

/* 대화 목록 */
.chat__list-view { background: var(--card); padding-bottom: 90px; gap: 2px; }
.chat__title { margin: 6px 4px 10px; font-size: 1.45rem; font-weight: 800; }
.chat__thread { display: flex; gap: 12px; padding: 12px 10px; border-radius: 14px; color: inherit; text-decoration: none; }
.chat__thread:hover { background: var(--chat-soft); text-decoration: none; }
.chat__thread .chat__avatar { width: 44px; height: 44px; border-radius: 15px; }
.chat__thread .chat__avatar--staff { border-radius: 50%; }
.chat__thread .chat__avatar img { width: 36px; }
.chat__thread-body { flex: 1; min-width: 0; display: grid; gap: 3px; }
.chat__thread-top { display: flex; align-items: center; gap: 8px; }
.chat__thread-top strong { font-size: .95rem; }
.chat__thread-date { font-size: .8rem; color: var(--ink-muted); }
.chat__thread-text { font-size: .9rem; color: #333; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chat__state { margin-left: auto; font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: var(--chat-soft); color: var(--ink-muted); white-space: nowrap; }
.chat__state--new { background: #fde8e8; color: #c4312b; font-weight: 700; }
.chat__empty { margin: 40px 0; text-align: center; color: var(--ink-muted); }

/* 아래 탭 */
.chat__tabs { display: flex; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-top: 1px solid var(--line); }
.chat__tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 0 10px; font-size: .74rem; color: #9a9a95; text-decoration: none; }
.chat__tab:hover { text-decoration: none; color: var(--ink); }
.chat__tab[aria-current="page"] { color: var(--accent); font-weight: 700; }

/* 대화 */
.chat__convhead { display: flex; align-items: center; gap: 8px; padding: 10px 52px 10px 8px; background: var(--card); border-bottom: 1px solid var(--line); }
.chat__convhead strong { display: block; font-size: .95rem; }
.chat__convhead small { display: block; font-size: .74rem; color: var(--ink-muted); }
.chat__iconbtn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--ink); }
.chat__iconbtn:hover { background: var(--chat-soft); }
.chat__log { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; background: var(--card); }
.chat__row { display: flex; gap: 8px; align-items: flex-start; max-width: 92%; }
.chat__row-body { display: grid; gap: 3px; min-width: 0; }
.chat__name { font-size: .76rem; color: var(--ink-muted); font-weight: 600; }
.chat__msg { max-width: 82%; padding: 10px 14px; border-radius: 18px; font-size: .93rem; line-height: 1.55; word-break: keep-all; overflow-wrap: anywhere; }
.chat__row .chat__msg { max-width: 100%; }
.chat__msg--bot { align-self: flex-start; background: var(--chat-soft); border-top-left-radius: 6px; }
.chat__msg--me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 6px; }
.chat__log > .chat__msg--notice { align-self: center; max-width: 90%; text-align: center; font-size: .82rem; background: var(--accent-soft); color: var(--accent-strong); border-radius: 12px; }
.chat__typing { display: flex; gap: 4px; margin-left: 44px; padding: 14px 16px; }
.chat__typing i { width: 7px; height: 7px; border-radius: 50%; background: #a3a39e; animation: chat-dot 1.2s infinite ease-in-out; }
.chat__typing i:nth-child(2) { animation-delay: .15s; }
.chat__typing i:nth-child(3) { animation-delay: .3s; }
@keyframes chat-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .chat__typing i { animation: none; } .chat__fab { transition: none; } }

/* 담당자에게 넘기기 */
.chat__handoff { align-self: stretch; margin-left: 44px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.chat__handoff-form { display: grid; gap: 4px; font-size: .85rem; }
.chat__handoff-form label { font-weight: 600; margin-top: 4px; }
.chat__handoff-form select, .chat__handoff-form textarea, .chat__handoff-form input[type=text] { font: inherit; font-size: .9rem; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; width: 100%; background: #fff; }
.chat__hint { margin: 2px 0; color: var(--ink-muted); font-size: .78rem; }
.chat__hint--center { text-align: center; margin-top: 10px; }
.chat__hint--error { color: var(--bad-ink); }
.chat__btn { margin-top: 6px; border: 0; border-radius: 999px; padding: 10px 14px; background: var(--accent); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }

/* 입력 */
.chat__form { padding: 10px 12px 12px; background: var(--card); }
.chat__field { display: flex; align-items: flex-end; gap: 6px; padding: 6px 6px 6px 16px; border: 1.5px solid var(--line); border-radius: 24px; background: #fff; transition: border-color .15s; }
.chat__field:focus-within { border-color: var(--accent); }
.chat__field textarea { flex: 1; resize: none; border: 0; outline: 0; font: inherit; font-size: .95rem; padding: 7px 0; max-height: 96px; background: transparent; }
.chat__send { flex: 0 0 auto; width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--accent); color: #fff; cursor: pointer; }
.chat__send:disabled { opacity: .45; cursor: wait; }

@media (max-width: 600px) {
  .chat__fab { right: 16px; bottom: 16px; width: 64px; height: 64px; border-radius: 20px; }
  .chat__panel { inset: 0; width: auto; height: auto; border-radius: 0; }
  body.chat-open { overflow: hidden; }
  body.chat-open .chat__fab { display: none; }
  .chat__field textarea { font-size: 16px; } /* iOS 확대 방지 */
}
