
#saju-widget-host{
    position: fixed;
    right: 24px;
    bottom: 54px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
}


#saju-launcher {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-items: end;
    gap: 4px;
    min-width: 140px;
    padding: 10px 18px 12px;
    border-radius: 16px;
    border: 1px solid rgba(0,0,0,.10);
    box-shadow: 0 6px 20px rgba(0,0,0,.12);
    background: #fff;
    color: #111;
    cursor: pointer;
    user-select: none;
    font-family: inherit;
}

#saju-launcher .saju-launcher-free {
    font-size: 12px;
    font-weight: 700;
    color: #13678A;
    text-align:end;
}

#saju-launcher .saju-launcher-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
    text-align: right;
}

#saju-launcher:active {
    transform: translateY(1px);
}

#saju-widget{
    width: calc(100vw - 24px);
    max-width: min(360px, calc(100vw - 12px));
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 12px 30px rgba(0,0,0,.14);
    box-sizing: border-box;
    background: #fff;
    display: none;
    margin-bottom: 10px;
    border: 1px solid rgba(0,0,0,.08);
    position: relative;
    z-index: 1;
}

.saju-header{
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 800;
    border-bottom: 1px solid rgba(0,0,0,.08);
    display:flex;
    justify-content: space-between;
    align-items:center;
    gap: 10px;
    background:#fff;
}
.saju-header .title{ display:flex; align-items:center; gap:8px; }
.saju-header .dot{ width:8px;height:8px;border-radius:99px;background:#111;opacity:.9; }
.saju-mini-btn{
    border: 1px solid rgba(0,0,0,.14);
    background:#fff;
    color:#111;
    border-radius: 10px;
    padding: 8px 10px;
    font-weight: 700;
    cursor:pointer;
}

.saju-body{ 
    padding: 12px 14px 14px; 
    min-height: 380px;
}

.saju-grid{ display:grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.saju-row{ display:flex; flex-direction: column; gap: 6px; min-width: 0; }
.saju-label{ font-size: 12px; opacity: .75; }

.saju-input{
    min-width:0;
}

.saju-input, .saju-select{
    width: 100%;
    box-sizing: border-box;
    padding: 10px 10px;
    border: 1px solid rgba(0,0,0,.14);
    border-radius: 10px;
    font-size: 16px;
    outline: none;
    background: #fff;
    min-height: 40px;
}
.saju-input:focus, .saju-select:focus{
    border-color: rgba(0,0,0,.35);
    box-shadow: 0 0 0 3px rgba(0,0,0,.06);
}

#saju-birth {
    -webkit-appearance: none;
    appearance: none;
    min-height: 44px;
}

.saju-actions{ display:flex; gap: 8px; margin-top: 12px; }
.saju-btn{
    flex: 1;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,.14);
    background: #111;
    color:#fff;
    font-size: 14px;
    cursor:pointer;
    font-weight: 800;
}
.saju-btn.secondary{ background:#fff; color:#111; }

.saju-help{ margin-top: 10px; font-size: 12px; opacity: .7; }

.saju-result{
    margin-top: 12px;
    padding: 12px 12px;
    border: 1px solid rgba(0,0,0,.10);
    border-radius: 10px;
    background: rgba(0,0,0,.03);
    font-size: 13px;
    line-height: 1.55;
    display:none;
}
.saju-result .row{
    display:flex;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px dashed rgba(0,0,0,.10);
}
.saju-result .row:last-child{ border-bottom: 0; }
.saju-result .k{ font-weight: 700; opacity: .85; }
.saju-result .v{ font-weight: 900; }

/* === Chat === */
.saju-chat{
    display:none;
}

#saju-widget-host #chat-remaining {
  font-weight: 700;
  min-width: 80px;
  white-space: nowrap;
}

.saju-calc,
.saju-chat{
    width:100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;

}
.chat-log{
    height: 260px;
    min-height: 240px;
    overflow:auto;
    border: 1px solid rgba(0,0,0,.10);
    border-radius: 12px;
    padding: 10px;
    background: rgba(0,0,0,.02);
    font-size: 13px;
    line-height: 1.55;
    white-space: pre-wrap;
}
.chat-msg{ margin: 8px 0; }
.chat-me{ font-weight: 800; }
.chat-bot{ font-weight: 800; }
.chat-meta{
    margin-top: 8px;
    font-size: 12px;
    opacity: .75;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.chat-meta-left{
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex: 1;
}
.chat-meta-left #chat-ganji{
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-meta-right{
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}
.chat-input-row{
    margin-top: 10px;
    display:flex;
    gap: 8px;
}
.chat-input-row input{
    flex:1;
}

.saju-calc,
.saju-chat {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

@media (max-width: 480px){
    #saju-launcher {
    min-width: 120px;
    padding: 8px 14px 10px;
    }

    #saju-launcher .saju-launcher-text {
    font-size: 16px;
    }

    #saju-widget-host{
    bottom: 12px;
    }

    
    #saju-widget{ 
    width: calc(100vw - 24px);
    max-width: 340px;
    margin: 0 auto;
    min-height: 420px;
    }
    

    .saju-body{
    min-height: 380px;
    }

    .chat-log{ 
    min-height: 240px;
    }
    
}
    
    /* 로딩 스피너 */
.saju-spinner{
    width: 16px; height: 16px;
    border-radius: 999px;
    border: 2px solid rgba(255,255,255,.35);
    border-top-color: rgba(255,255,255,1);
    animation: sajuSpin .8s linear infinite;
    display:none;
}
    @keyframes sajuSpin { to { transform: rotate(360deg); } }

    .saju-btn[disabled]{ opacity:.6; cursor:not-allowed; }
    .saju-input[disabled], .saju-select[disabled]{ opacity:.75; }

        .typing-dots::after{
    content: "…";
    display: inline-block;
    width: 1.2em;
    animation: typingDots 1s steps(3, end) infinite;
}
    
@keyframes typingDots{
    0% { content:""; }
    33% { content:"."; }
    66% { content:".."; }
    100% { content:"..."; }
}

/* ✅ 테마 CSS 영향 차단: 채팅 영역은 무조건 좌정렬/정상 플로우 */
#saju-widget-host .chat-log{
  text-align: left !important;
}

#saju-widget-host #saju-birth {
  width: 100%;
  box-sizing: border-box;
  font-size: 16px; /* 모바일 줌 방지 */
}

/* 상담 입력창 줌 방지 - 모바일 */
#saju-widget-host #chat-input {
  font-size: 16px !important;
  min-height: 44px;
}

#saju-widget-host .chat-msg{
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start !important;
  margin: 4px 0;
}


/* 말풍선 공통 스타일 */
#saju-widget-host .chat-bubble{
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,.10);
  background: #fff;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 봇 말풍선 안의 "혜광" 라벨 */
#saju-widget-host .chat-bubble-header{
  font-weight: 800;
  font-size: 12px;
  opacity: .75;
  line-height: 1.2;
  margin: 0 0 4px 0;
}

#saju-widget-host .chat-bubble-body{
  margin: 0;
  padding: 0;
}

/* 사용자: 오른쪽 정렬 + 회색 배경 */
#saju-widget-host .chat-msg.me{
  justify-content: flex-end !important;
}
#saju-widget-host .chat-msg.me .chat-bubble{
  background: rgba(0,0,0,.05);
}

#saju-widget-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;  /* 동적 뷰포트 - 모바일 주소창 대응 */
  z-index: 0;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background: rgba(0, 0, 0, 0.15);
  pointer-events: none;
}

/* 데스크톱: 백드롭 숨김 (모바일에서만 사용) */
#saju-widget-host.is-open #saju-widget-backdrop {
  display: none;
  pointer-events: none;
}

.saju-chat-textarea {
  resize: none;
  min-height: 40px;
  max-height: 120px;
  line-height: 1.4;
}

/* 모바일: 위젯 열렸을 때만 백드롭 표시 */
@media (max-width: 768px) {
  #saju-widget-host {
    right: 12px;
  }

  #saju-widget-host.is-open #saju-widget-backdrop {
    display: block;
    pointer-events: auto;
  }
  
  /* 모바일에서 z-index를 더 크게 해서 모든 요소 위에 */
  #saju-widget-host.is-open {    
    right: 12px;
    margin:0;
    z-index: 2147483647;  /* 최대값 - 테마 요소보다 위에 */
  }

  /* 위젯이 백드롭 위에 오도록 */
  #saju-widget-host.is-open #saju-widget {
    position: relative;
    z-index: 1;
  }
}
