/* ============ kakao-fab — 카카오톡 상담 버튼(K1) + 누르면 열리는 상담 패널 (10/13) ============
   모바일 = 아래에서 올라오는 시트 + 어두운 바탕 / 데스크탑 = 버튼 위로 펼쳐지는 카드.
   홈 2(lab/hero-usim)는 이 파일 사본(kfab.css)을 쓴다 — 고치면 사본도 다시 복사. */
.kfab { --kf-y: #FEE500; --kf-ink: #191600; --kf-bg: #F3F6FC; --kf-text: #14171F; --kf-text-2: #505869;
  position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 8500;
  font-family: "Pretendard", "Pretendard Variable", -apple-system, sans-serif; -webkit-font-smoothing: antialiased; word-break: keep-all; }
@media (max-width: 768px) { body:has(.bnav:not([data-off])) .kfab { bottom: calc(var(--bnav-h, 48px) + env(safe-area-inset-bottom, 0px) + 22px); } }
.kfab button, .kfab a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.kfab :focus-visible { outline: 3px solid #1463FF; outline-offset: 3px; }

/* 동그라미 버튼 */
.kfab__btn { position: relative; z-index: 2; display: grid; place-items: center; width: 60px; height: 60px; border: 0; border-radius: 50%; padding: 0; cursor: pointer;
  background: var(--kf-y); box-shadow: 0 10px 20px rgba(0,0,0,.22); transition: transform .4s cubic-bezier(.16,1,.3,1); }
.kfab__btn:hover { transform: scale(1.08); }
.kfab__btn:active { transform: scale(.94); transition-duration: .1s; }
.kfab__btn svg { position: absolute; width: 30px; height: 30px; transition: transform .45s cubic-bezier(.16,1,.3,1), opacity .25s; }
.kfab__btn .x { width: 22px; height: 22px; opacity: 0; transform: rotate(-90deg) scale(.4); }
.kfab.is-open .kfab__btn .talk { opacity: 0; transform: rotate(90deg) scale(.4); }
.kfab.is-open .kfab__btn .x { opacity: 1; transform: none; }
.kfab__tip { display: none; position: absolute; right: 80px; top: 50%; transform: translateY(-50%); white-space: nowrap; background: #0E1220; color: #fff;
  font-size: 14px; font-weight: 700; padding: 9px 13px; border-radius: 10px; transition: opacity .2s; pointer-events: none; }
.kfab.is-open .kfab__tip, .kfab.tip-off .kfab__tip { opacity: 0; visibility: hidden; transition: opacity .4s, visibility 0s .4s; }

/* 패널 */
.kfab__dim { position: fixed; inset: 0; z-index: 1; background: rgba(8,12,28,.42); opacity: 0; transition: opacity .3s; }
.kfab__dim[hidden] { display: none; }
.kfab.is-open .kfab__dim { opacity: 1; }
.kfab__panel { position: fixed; z-index: 3; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column;
  max-height: 82vh; max-height: 82dvh; background: #fff; color: var(--kf-text); border-radius: 22px 22px 0 0; box-shadow: 0 -10px 40px rgba(0,0,0,.18);
  padding-bottom: env(safe-area-inset-bottom, 0px); transform: translateY(104%); transition: transform .42s cubic-bezier(.16,1,.3,1); visibility: hidden; }
.kfab.is-open .kfab__panel { transform: none; visibility: visible; }
.kfab__grip { width: 40px; height: 5px; border-radius: 9px; background: #D7DEEC; margin: 10px auto 0; flex: none; }

.kfab__head { flex: none; display: flex; align-items: center; gap: 12px; padding: 14px 16px 14px 20px; }
.kfab__head i { flex: none; width: 42px; height: 42px; border-radius: 14px; background: var(--kf-y); display: grid; place-items: center; }
.kfab__head i svg { width: 24px; height: 24px; }
.kfab__head div { flex: 1; min-width: 0; }
.kfab__head b { display: block; font-size: 17px; letter-spacing: -.02em; }
.kfab__head span { display: block; margin-top: 2px; font-size: 13px; color: var(--kf-text-2); }
.kfab__close { flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--kf-bg); display: grid; place-items: center; cursor: pointer; color: var(--kf-text); }
.kfab__close svg { width: 14px; height: 14px; }

.kfab__body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; background: var(--kf-bg); padding: 18px 16px 8px; }
.kfab__msg { display: flex; margin-bottom: 10px; }
.kfab__msg p { margin: 0; max-width: 82%; padding: 11px 14px; font-size: 15px; line-height: 1.5; border-radius: 4px 16px 16px 16px; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.04); }
.kfab__msg--me { justify-content: flex-end; }
.kfab__msg--me p { background: var(--kf-y); color: var(--kf-ink); border-radius: 16px 4px 16px 16px; font-weight: 600; }
.kfab__msg.is-new { animation: kfIn .36s cubic-bezier(.16,1,.3,1) both; }
.kfab__typing p { display: flex; gap: 4px; padding: 14px; }
.kfab__typing i { width: 7px; height: 7px; border-radius: 50%; background: #AEB6C8; animation: kfDot 1s ease-in-out infinite; }
.kfab__typing i:nth-child(2) { animation-delay: .15s; } .kfab__typing i:nth-child(3) { animation-delay: .3s; }

.kfab__chips { flex: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px 4px; background: #fff; border-top: 1px solid #E8EBF2; }
.kfab__chips button { border: 1.5px solid #D7DEEC; background: #fff; color: var(--kf-text); border-radius: 99px; padding: 8px 13px; font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; transition: border-color .2s, background .2s; }
.kfab__chips button:hover { border-color: #1463FF; }
.kfab__chips button[aria-pressed="true"] { border-color: #1463FF; background: #EAF1FF; color: #0B47C9; }
.kfab__go { flex: none; display: flex; align-items: center; justify-content: center; gap: 8px; margin: 12px 16px 14px; height: 54px; border-radius: 14px;
  background: var(--kf-y); color: var(--kf-ink); text-decoration: none; font-size: 16px; font-weight: 800; }
.kfab__go svg { width: 22px; height: 22px; }
.kfab__go:disabled { border: 0; width: calc(100% - 32px); font-family: inherit; cursor: not-allowed; opacity: .55; }

@keyframes kfIn { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes kfDot { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes kfNudge { 0%, 70%, 100% { transform: none; } 76% { transform: rotate(-10deg); } 82% { transform: rotate(8deg); } 88% { transform: rotate(-4deg); } }
@media (prefers-reduced-motion: no-preference) { .kfab:not(.is-open):not(.was-open) .kfab__btn { animation: kfNudge 4s ease-in-out 2s infinite; } }
@media (prefers-reduced-motion: reduce) { .kfab__panel, .kfab__btn svg { transition: none; } .kfab__msg.is-new, .kfab__typing i { animation: none; } }

/* 데스크탑: 버튼 위로 펼쳐지는 카드(바탕 어둡게 안 함) */
@media (min-width: 1024px) {
  .kfab { right: 32px; bottom: 32px; }
  .kfab__btn { width: 68px; height: 68px; }
  .kfab__tip { display: block; }
  .kfab__dim { display: none !important; }
  .kfab__panel { position: absolute; left: auto; right: 0; bottom: 84px; width: 380px; height: 560px; max-height: calc(100vh - 140px);
    border-radius: 24px; box-shadow: 0 24px 60px rgba(0,0,0,.24); padding-bottom: 0; transform-origin: 100% 100%;
    transform: scale(.4) translate(30px, 40px); opacity: 0; filter: blur(6px);
    transition: transform .42s cubic-bezier(.16,1,.3,1), opacity .25s, filter .3s, visibility 0s .42s; }
  .kfab.is-open .kfab__panel { transform: none; opacity: 1; filter: none; transition: transform .42s cubic-bezier(.16,1,.3,1), opacity .25s, filter .3s, visibility 0s; }
  .kfab__grip { display: none; }
  .kfab__head { padding-top: 18px; }
}
