
@font-face {
    font-family: "Shilla_Culture(B)";
    src: url("../fonts/shilla-culture-b.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* 테마 푸터·우측 세로문구(.sidebar-text)·헤더보다 항상 위 — 별도 스택 컨텍스트로 겹침 고정 */
#saju-widget-host {
    /* 봇 이름(.chat-bubble-bot-name) font-size calc — 프로필 없는 말풍선에서도 동일 비율 */
    --chat-bot-avatar-size: 36px;
    position: fixed;
    right: 24px;
    bottom: 54px;
    /* 푸터·sidebar-text·본문 스택 위 — 테마 덮어쓰기 방지 */
    z-index: 2147483647 !important;
    isolation: isolate;
    opacity: 1;
    pointer-events: auto;
    font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
    /* hyegwang-classic 테마 토큰과 동일 */
    --saju-npc-w: 800;
    --saju-npc-h: 1136;
    --hw-ink: #2d2926;
    --hw-accent: #8e6e53;
    --hw-cream: #f6f4f1;
    --hw-ink-hover: #3d3834;
    --hw-accent-dim: #6b5542;
}

/* 플로팅: 말풍선(꼬리 없음) + 런처 버튼 */
.saju-launcher-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

.saju-launcher-bubble {
    flex-shrink: 0;
    max-width: min(280px, calc(100vw - 48px));
    padding: 11px 15px;
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.09);
    box-shadow: 0 5px 22px rgba(0, 0, 0, 0.11);
    background: #ffffff;
    color: #1a1a1a;
    box-sizing: border-box;
}

.saju-launcher-bubble__inner {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.5;
    letter-spacing: -0.02em;
    text-align: right;
    word-break: keep-all;
}

.saju-launcher-bubble__text {
    white-space: pre-wrap;
}

.saju-launcher-bubble__caret {
    display: inline-block;
    width: 2px;
    height: 1.05em;
    margin-left: 2px;
    vertical-align: -0.15em;
    background: var(--hw-accent);
    border-radius: 1px;
    animation: sajuLauncherCaretBlink 1s steps(1, end) infinite;
}

@keyframes sajuLauncherCaretBlink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .saju-launcher-bubble__caret {
        animation: none;
        opacity: 0.45;
    }
}

#saju-widget-host.is-open .saju-launcher-stack {
    display: none;
}

#saju-launcher {
    display: grid;
    justify-items: end;
    gap: 4px;
    min-width: 140px;
    padding: 10px 18px 12px;
    border-radius: 16px;
    border: 1px solid #1c1c1c;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
    background: #1c1c1c;
    color: #fff;
    cursor: pointer;
    user-select: none;
    font-family: inherit;
    text-decoration: none;
    box-sizing: border-box;
}

#saju-launcher:hover,
#saju-launcher:focus-visible {
    background: #111;
    border-color: #111;
    color: #fff;
}

#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));
    /* 패널 높이 고정 → 본문(.saju-body)만 스크롤 */
    height: min(92vh, 720px);
    max-height: min(92vh, 720px);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 12px 30px rgba(0,0,0,.14);
    box-sizing: border-box;
    background: #fff;
    display: none;
    flex-direction: column;
    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;
    flex-wrap: wrap;
    min-width: 0;
    flex-shrink: 0;
}
.saju-header .title{
    display:flex;
    align-items:center;
    gap:8px;
    min-width: 0;
    flex: 1 1 auto;
}
.saju-header-actions{
    flex: 0 1 auto;
    flex-shrink: 0;
    min-width: min-content;
    max-width: 100%;
}
.saju-header .dot{ width:8px;height:8px;border-radius:99px;background:var(--hw-accent);opacity:.95; }
.saju-mini-btn{
    border: 1px solid rgba(45, 41, 38, 0.18);
    background:#fff;
    color: var(--hw-ink);
    border-radius: 10px;
    padding: 8px 10px;
    font-weight: 700;
    cursor:pointer;
}
/* 로그인은 <a class="saju-mini-btn"> — 버튼과 동일한 박스 */
#saju-widget-host a.saju-mini-btn{
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    font-size: inherit;
    font-family: inherit;
    line-height: 1.2;
    -webkit-appearance: none;
    appearance: none;
}
#saju-widget-host a.saju-mini-btn:hover{
    background: rgba(142, 110, 83, 0.08);
    color: var(--hw-ink);
    border-color: rgba(142, 110, 83, 0.35);
}
#saju-widget-host button.saju-mini-btn:hover,
#saju-widget-host button.saju-mini-btn:focus-visible {
    background: rgba(142, 110, 83, 0.08);
    color: var(--hw-ink);
    border-color: rgba(142, 110, 83, 0.35);
    outline: none;
}

/* 게스트/회원 전환: data-saju-auth 만 사용 */
#saju-widget-host[data-saju-auth="guest"] .saju-header-user-only {
    display: none;
}

.saju-body{ 
    padding: 12px 14px 14px; 
    min-height: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    /* 고정 높이 패널 안에서 계산·결과·버튼까지 한 영역 스크롤 */
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* contain 제거: 끝에서 문서 스크롤로 이어지기 쉽게(브라우저 네이티브 체인) */
    overscroll-behavior: auto;
}

.saju-grid{ display:grid; grid-template-columns: 1fr 1fr; gap: 10px; }

#saju-widget-host #saju-calc .saju-grid {
  grid-template-columns: 7fr 3fr;
}
.saju-row{ display:flex; flex-direction: column; gap: 6px; min-width: 0; }
.saju-label{ font-size: 12px; opacity: .75; }

.saju-birth-control-row{
    display: flex;
    align-items: stretch;
    gap: 8px;
    width: 100%;
    min-width: 0;
}
.saju-birth-control-row .saju-calendar-select{
    flex: 0 0 116px;
    width: 116px;
    min-height: 44px;
}
.saju-birth-control-row .saju-birth-wrap{
    flex: 1 1 auto;
    min-width: 0;
}
.saju-input{
    min-width:0;
}

.saju-input, .saju-select{
    width: 100%;
    box-sizing: border-box;
    padding: 10px 10px;
    border: 1px solid rgba(45, 41, 38, 0.16);
    border-radius: 10px;
    font-size: 16px;
    outline: none;
    background: #fff;
    min-height: 40px;
}
.saju-select{
    padding: 10px 34px 10px 10px;
    -webkit-appearance: none;
    appearance: none;
    color: var(--hw-ink);
    -webkit-text-fill-color: var(--hw-ink);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23554c45' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px 14px;
}
.saju-input:focus, .saju-select:focus{
    border-color: rgba(142, 110, 83, 0.55);
    box-shadow: 0 0 0 3px rgba(142, 110, 83, 0.12);
}

.saju-birth-wrap{
    display: flex;
    align-items: stretch;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
    /* 입력창–달력 사이 + 우측 포커스 링(갈색)이 overflow 부모에 잘리지 않도록 */
    padding-right: 6px;
}
.saju-birth-wrap .saju-birth-text{
    flex: 1;
    min-width: 0;
    -webkit-appearance: none;
    appearance: none;
    min-height: 44px;
    font-variant-numeric: tabular-nums;
}
/* 달력: label + 네이티브 type=date (appearance 제거 필수 — 없으면 PC/모바일에서 피커가 안 뜸) */
.saju-birth-cal-slot{
    position: relative;
    flex: 0 0 44px;
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    align-self: stretch;
}
.saju-birth-cal-slot .saju-birth-cal-label{
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    min-height: 44px;
    margin: 0;
    padding: 0;
    cursor: pointer;
    touch-action: manipulation;
}
.saju-birth-cal-slot .saju-birth-cal-btn{
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(45, 41, 38, 0.16);
    border-radius: 10px;
    background: #fff;
    color: var(--hw-ink);
    pointer-events: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.saju-birth-cal-slot:hover .saju-birth-cal-btn,
.saju-birth-cal-slot:focus-within .saju-birth-cal-btn{
    border-color: rgba(142, 110, 83, 0.55);
    /* 링이 잘리지 않게 spread를 살짝 줄임(3px→2px) + 동일 톤 유지 */
    box-shadow: 0 0 0 2px rgba(142, 110, 83, 0.14);
}
.saju-birth-cal-slot .saju-birth-cal-btn svg{
    display: block;
}
.saju-birth-cal-slot .saju-birth-picker-native{
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    /* 완전 투명은 일부 브라우저에서 히트 테스트 실패 — 네이티브 appearance 유지 */
    opacity: 0.011;
    cursor: pointer;
    z-index: 2;
    font-size: 16px;
    min-height: 44px;
    line-height: 44px;
    box-sizing: border-box;
    -webkit-appearance: auto;
    appearance: auto;
}
/* 테마 리셋이 date appearance를 막는 경우 */
#saju-widget-host .saju-birth-picker-native {
    -webkit-appearance: auto !important;
    appearance: auto !important;
}

.saju-actions{ display:flex; gap: 8px; margin-top: 12px; }
.saju-btn{
    flex: 1;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--hw-ink);
    background: var(--hw-ink);
    color: var(--hw-cream);
    font-size: 14px;
    cursor:pointer;
    font-weight: 800;
    letter-spacing: 0.04em;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.saju-btn:hover,
.saju-btn:focus-visible {
    background: var(--hw-ink-hover);
    border-color: var(--hw-ink-hover);
    outline: none;
}
.saju-btn:focus-visible {
    box-shadow: 0 0 0 2px rgba(142, 110, 83, 0.45);
}
.saju-btn.secondary{
    background: #fff;
    color: var(--hw-ink);
    border-color: rgba(45, 41, 38, 0.2);
    letter-spacing: 0;
}
.saju-btn.secondary:hover,
.saju-btn.secondary:focus-visible {
    background: rgba(142, 110, 83, 0.06);
    border-color: rgba(142, 110, 83, 0.45);
    color: var(--hw-ink);
    box-shadow: none;
}

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

/* 계산·초기화 바로 아래에 대화 시작 버튼 배치 */
#saju-calc > .saju-grid + .saju-actions{
    margin-bottom: 0;
}

#saju-widget-host #saju-calc {
  box-sizing: border-box;
}

/* 위젯 호스트 정렬 */
#saju-widget-host.is-open {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

#saju-widget-host #saju-calc #saju-gochat-wrap {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  margin-top: 8px;
  margin-bottom: 12px;
  padding: 0;
}

#saju-widget-host #saju-calc #saju-gochat-wrap.is-disabled {
  display: none;
}

#saju-widget-host #saju-gochat-wrap .saju-btn {
  width: 100%;
}

.saju-character-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  align-items: stretch;
  gap: 10px;
  width: 100%;
}

.saju-character-card-grid > :last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.saju-character-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  box-sizing: border-box;
  padding: 14px 12px 12px;
  border: 1px solid rgba(142, 110, 83, 0.22);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(57, 47, 40, 0.06);
}

.saju-character-card--sukja {
  position: relative;
  border-color: rgba(170, 104, 77, 0.24);
  background: linear-gradient(180deg, #fffdf9 0%, #fbf5ed 100%);
}

.saju-character-card--cheoneul {
  position: relative;
  border-color: rgba(92, 64, 32, 0.35);
  background: linear-gradient(180deg, #fffaf3 0%, #f3e6d4 100%);
}

.saju-character-card--cheoneul .saju-character-card__recommend {
  background: #5c4020;
}

.saju-character-card__recommend {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  padding: 2px 7px;
  border-radius: 10px;
  background: #aa684d;
  color: #fffdf9;
  font-family: "Shilla_Culture(B)", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.02em;
}

.saju-character-card .saju-gochat-intro {
  flex: 1 1 auto;
  justify-content: flex-start;
  margin-bottom: 12px;
  padding: 0;
}

.saju-character-card__name {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  color: var(--hw-ink);
  font-size: 14px;
  line-height: 1.35;
  text-align: center;
}

.saju-character-card .saju-gochat-intro__message,
.saju-character-card .saju-result-chat-cta__message {
  flex: 1 1 auto;
  margin-bottom: 0;
  font-size: 12px;
  line-height: 1.6;
}

.saju-character-card__tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px 8px;
  margin: 0 0 10px;
  padding: 0;
}

.saju-character-card__tag {
  color: var(--hw-accent);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.3;
  word-break: keep-all;
}

.saju-character-card .saju-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 58px;
  min-height: 58px;
  height: 58px;
  padding: 9px 8px;
  font-size: 14px;
  line-height: 1.35;
  letter-spacing: 0;
  text-align: center;
  white-space: normal;
  word-break: keep-all;
}

.saju-character-card--media {
  justify-content: flex-end;
  align-self: start;
  aspect-ratio: 222 / 320;
  width: 100%;
  height: auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.saju-character-card--media::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  z-index: 1;
  height: 52%;
  background: linear-gradient(180deg, rgba(28, 22, 18, 0) 0%, rgba(28, 22, 18, 0.78) 72%);
  pointer-events: none;
}

.saju-character-card--media .saju-gochat-intro {
  position: absolute;
  inset: 0;
  flex: none;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border-radius: 0;
  pointer-events: none;
}

.saju-character-card--media .saju-character-card__video {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: transparent;
}

.saju-character-card--hyegwang .saju-character-card__recommend {
  background: var(--hw-ink);
}

.saju-character-card--media .saju-character-card__tags {
  position: relative;
  z-index: 2;
  margin: 0 8px 6px;
}

.saju-character-card--media .saju-character-card__tag {
  color: #fffdf9;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

#saju-widget-host #saju-gochat-wrap .saju-character-card--media .saju-btn {
  position: relative;
  z-index: 2;
  width: calc(100% - 16px);
  height: auto;
  min-height: 0;
  flex: 0 0 auto;
  margin: 0 8px 8px;
  padding-top: 8px;
  padding-bottom: 8px;
  background: #fffdf9;
  border-color: rgba(255, 253, 249, 0.85);
  color: #2d2926;
  opacity: 0.7;
}
#saju-widget-host #saju-gochat-wrap .saju-character-card--media .saju-btn:hover,
#saju-widget-host #saju-gochat-wrap .saju-character-card--media .saju-btn:focus-visible {
  background: #fff;
  border-color: #fff;
  color: #1c1612;
}

.saju-gochat-intro__avatar--sukja {
  border-color: rgba(170, 104, 77, 0.24);
  background: #ead3c1;
  color: #704a38;
}

.saju-gochat-intro__avatar--cheoneul {
  border-color: rgba(92, 64, 32, 0.45);
  background: #2a2118;
  color: #f3e6d4;
}

.saju-gochat-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 10px;
  padding: 10px 0;
  box-sizing: border-box;
  text-align: center;
}

.saju-gochat-intro__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 50%;
  background: var(--hw-cream, #f7f2ea);
  color: var(--hw-ink);
  font-size: 11px;
  font-weight: 800;
}

.saju-gochat-intro__avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.saju-gochat-intro__message {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  color: var(--hw-ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.65;
  text-align: center;
  white-space: pre-line;
  word-break: keep-all;
}

#saju-widget-host #saju-gochat:not(:disabled) {
  background: var(--hw-ink);
  border-color: var(--hw-ink);
  color: var(--hw-cream);
}

#saju-widget-host #saju-gochat:not(:disabled):hover,
#saju-widget-host #saju-gochat:not(:disabled):focus-visible {
  background: var(--hw-ink-hover);
  border-color: var(--hw-ink-hover);
  color: var(--hw-cream);
}

#saju-widget-host #saju-gochat:disabled,
#saju-widget-host #saju-gochat:disabled:hover,
#saju-widget-host #saju-gochat:disabled:focus-visible {
  opacity: 1;
  cursor: not-allowed;
  background: #d8d5d1;
  border-color: #c8c4bf;
  color: #88827c;
  box-shadow: none;
}

.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;
}
/* 내정보와 동일 Figma 4열 그리드 — saju-profile-pillars.css + render-pillar-grid */
#saju-widget-host #saju-result.saju-result--figma{
    padding: 0;
    border: none;
    background: transparent;
}
#saju-widget-host #saju-result .saju-calc-result-stack{
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
    max-width: 100%;
}

#saju-widget-host .saju-result-chat-cta {
  margin-top: 14px;
  margin-bottom: 0;
  padding: 16px 14px;
  border: 1px solid rgba(142, 110, 83, 0.28);
  border-radius: 12px;
  background: rgba(142, 110, 83, 0.07);
}

#saju-widget-host .saju-result-chat-cta[hidden] {
  display: none;
}

#saju-widget-host .saju-result-chat-cta__message {
  margin: 0 0 12px;
  color: var(--hw-ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.7;
  text-align: center;
  white-space: pre-line;
  word-break: keep-all;
}

#saju-widget-host .saju-result-chat-cta__button {
  width: 100%;
  background: var(--hw-ink);
  border-color: var(--hw-ink);
  color: var(--hw-cream);
}

#saju-widget-host .saju-result-chat-cta__button:hover,
#saju-widget-host .saju-result-chat-cta__button:focus-visible {
  background: var(--hw-ink-hover);
  border-color: var(--hw-ink-hover);
  color: var(--hw-cream);
}
/* 한 카드 안에 네 기둥 + 대운·세운 — saju-profile-pillars.css 의 .saju-profile-pillars--figma 하위 규칙이 먹도록 */
#saju-widget-host #saju-result .saju-calc-pillar-embed.saju-profile-pillars--figma{
    margin: 0;
    padding: 0.75rem 0.65rem 1rem;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    background: var(--saju-bg, #f7f7f6);
    max-width: 100%;
    box-sizing: border-box;
}
.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 .k .saju-calc-input-echo{
    font-weight: 600;
    margin-left: 6px;
    opacity: 0.92;
}
.saju-result .v{ font-weight: 900; }

/* === Chat === */
.saju-chat{
    display:none;
    position: relative;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
}

#saju-widget-host #chat-remaining {
  font-weight: 700;
  white-space: nowrap;
  text-align: right;
}
#saju-widget-host #chat-remaining:empty {
  display: none;
}

.saju-calc,
.saju-chat{
    width:100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}
.chat-log{
    flex: 1 1 auto;
    height: auto;
    min-height: 240px;
    max-height: none;
    overflow:auto;
    overscroll-behavior: 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;
}
#saju-widget-host .saju-npc-stage,
#saju-widget-host .saju-npc-stage__video,
#saju-widget-host.saju-chat-visible .saju-npc-stage__video {
    display: none !important;
}
#saju-widget-host .saju-npc-stage {
    position: relative;
    flex: 0 0 auto;
    min-height: 0;
    width: 100%;
    overflow: hidden;
    background: transparent;
}
#saju-widget-host .saju-npc-stage__frame {
    position: absolute;
    inset: 0;
    overflow: hidden;
}
#saju-widget-host .saju-npc-stage__video {
    display: none;
}
#saju-widget-host.saju-chat-visible .saju-npc-stage__video {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    pointer-events: none;
    background: transparent;
    opacity: 0.95;
}
#saju-widget-host.saju-chat-visible #saju-widget {
    background: #fff;
}
#saju-widget-host.saju-chat-visible .saju-header,
#saju-widget-host.saju-chat-visible .saju-body {
    position: relative;
    z-index: 1;
    background: #fff;
    color: inherit;
}
#saju-widget-host.saju-chat-visible .saju-header {
    border-bottom-color: rgba(0,0,0,.08);
    color: inherit;
}
#saju-widget-host.saju-chat-visible .chat-meta-left #chat-ganji,
#saju-widget-host.saju-chat-visible .chat-meta-left #chat-remaining {
    color: inherit;
    opacity: .75;
    text-shadow: none;
}
#saju-widget-host .saju-npc-dialogue {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 2px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    box-sizing: border-box;
    min-height: 92px;
    padding: 14px 16px 37px;
    border-radius: 12px;
    background: rgba(12, 10, 9, 0.75);
    color: #fffdf9;
}
#saju-widget-host .saju-npc-dialogue[hidden] {
    display: none !important;
}
#saju-widget-host .saju-npc-dialogue__line {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.55;
    align-self: flex-start;
    padding-left: 8px;
    text-align: left;
    word-break: keep-all;
    white-space: pre-line;
}
#saju-widget-host .saju-npc-dialogue__line.is-waiting::after {
    content: '.';
    display: inline-block;
    min-width: 1.5em;
    text-align: left;
    animation: sajuNpcWaitDots 1.6s steps(1, end) infinite;
}
@keyframes sajuNpcWaitDots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75%, 100% { content: '...'; }
}
#saju-widget-host .saju-npc-dialogue__ask {
    display: contents;
}
#saju-widget-host .saju-npc-dialogue__count {
    position: absolute;
    right: 12px;
    bottom: calc(100% + 6px);
    margin: 0;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    text-align: right;
    letter-spacing: 0.02em;
    color: #fffdf9;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}
#saju-widget-host .saju-npc-dialogue__question {
    position: absolute;
    left: 8px;
    right: 64px;
    bottom: calc(100% + 6px);
    margin: 0;
    overflow: hidden;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
    text-align: left;
    white-space: nowrap;
    text-overflow: ellipsis;
    word-break: keep-all;
    color: #fffdf9;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}
#saju-widget-host .saju-npc-dialogue__question[hidden] {
    display: none !important;
}
#saju-widget-host .saju-npc-dialogue__navs {
    position: absolute;
    right: 18px;
    bottom: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
}
#saju-widget-host .saju-npc-dialogue__nav {
    flex: 0 0 auto;
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #fffdf9;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}
#saju-widget-host .saju-npc-dialogue__nav:disabled {
    opacity: 0.35;
    cursor: default;
}
.chat-msg{ margin: 8px 0; }

/* 환영 인사 아래 추천 질문 · 답변 아래 맥락형 후속 질문(꼬리 없는 말풍선) */
.chat-starter-chips,
.chat-followup-chips {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    margin: 4px 0 4px;
    padding: 0 2px;
}
.chat-starter-chip,
.chat-followup-chip {
    display: block;
    max-width: 100%;
    margin: 0;
    padding: 10px 14px;
    border-radius: 14px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: #fff;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.06);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.45;
    letter-spacing: -0.02em;
    color: #1a1a1a;
    text-align: right;
    cursor: pointer;
    word-break: keep-all;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.chat-starter-chip:hover,
.chat-starter-chip:focus-visible,
.chat-followup-chip:hover,
.chat-followup-chip:focus-visible {
    border-color: rgba(142, 110, 83, 0.45);
    box-shadow: 0 4px 16px rgba(45, 41, 38, 0.1);
    background: rgba(142, 110, 83, 0.06);
    outline: none;
}
.chat-starter-chip:focus-visible,
.chat-followup-chip:focus-visible {
    outline: 2px solid var(--hw-accent);
    outline-offset: 2px;
}

.chat-meta{
    margin-top: 5px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.chat-meta-left #chat-ganji,
.chat-meta-left #chat-remaining{
    opacity: .75;
}
.chat-meta-left{
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex: 1;
    padding-left: 5px;
}
.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;
}

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

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

    .saju-launcher-bubble {
    padding: 9px 12px;
    border-radius: 14px;
    }

    .saju-launcher-bubble__inner {
    font-size: 12px;
    }

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

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

    .saju-body{
    min-height: 0;
    }

    .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; }

#saju-widget-host .chat-bubble-body .typing-dots {
  display: inline-block;
  min-width: 1.2em;
  min-height: 1.2em;
  vertical-align: baseline;
}

        .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:"..."; }
}

/* 초기 종합 리포트 API 대기 — 상태 문구 타이핑 후 페이드 순환 */
#saju-widget-host .chat-bubble-body--initial-report-wait {
  min-height: 1.4em;
}
#saju-widget-host .chat-initial-report-status {
  margin: 0;
  opacity: 0;
  transition: opacity 0.45s ease;
}
#saju-widget-host .chat-initial-report-status--visible {
  opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
  #saju-widget-host .chat-initial-report-status {
    transition: none;
    opacity: 1;
  }
}

/* 글자 크기 배율: 말풍선 + 과거 상담(달력·목록·한줄평) 공통 — JS가 #saju-chat에 갱신 */
#saju-widget-host #saju-chat {
  --saju-chat-font-scale: 1;
}

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

/* 대화 말풍선·칩 글자 크기 — JS가 --saju-chat-font-scale 갱신 */
#saju-widget-host .chat-log .chat-bubble-body,
#saju-widget-host .chat-log .chat-msg.me > .chat-bubble {
  font-size: calc(13px * var(--saju-chat-font-scale, 1));
}
#saju-widget-host .chat-log .chat-starter-chip {
  font-size: calc(14px * var(--saju-chat-font-scale, 1));
}
#saju-widget-host .chat-log .chat-followup-chip {
  font-size: 14px;
}
@media (max-width: 768px) {
  #saju-widget-host .chat-log .chat-starter-chip,
  #saju-widget-host .chat-log .chat-followup-chip {
    font-size: 14px !important;
    -webkit-appearance: none;
    appearance: none;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
}
#saju-widget-host .chat-log .chat-bubble-header {
  font-size: calc(12px * var(--saju-chat-font-scale, 1));
}
#saju-widget-host .chat-log .chat-bubble-bot-name {
  font-size: calc(var(--chat-bot-avatar-size, 36px) / 3 * var(--saju-chat-font-scale, 1));
}

/* 패널(#saju-widget) 아래 — 상담 화면일 때만 표시(JS: .saju-chat-visible) */
#saju-widget-host .chat-font-scale-row {
  display: none;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
  box-sizing: border-box;
  width: calc(100vw - 24px);
  max-width: min(360px, calc(100vw - 12px));
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

#saju-widget-host.is-open.saju-chat-visible .chat-font-scale-row {
  display: flex;
}
.chat-font-scale-label {
  font-size: 12px;
  opacity: 0.75;
  margin-right: 2px;
  white-space: nowrap;
}
.chat-font-scale-btn {
  flex: 0 0 auto;
  min-width: 44px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  color: #2d2926;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
/* 가- 한 단계 작게 · 가+ 한 단계 크게 */
.chat-font-scale-row .chat-font-scale-btn[data-saju-font-delta="-0.1"] {
  font-size: 12px;
}
.chat-font-scale-row .chat-font-scale-btn[data-saju-font-delta="0.1"] {
  font-size: 14px;
}
.chat-font-scale-btn:hover {
  border-color: rgba(142, 110, 83, 0.4);
  background: rgba(142, 110, 83, 0.08);
}
.chat-font-scale-btn:focus-visible {
  outline: 2px solid var(--hw-accent, #8e6e53);
  outline-offset: 2px;
}
.chat-font-scale-range {
  flex: 1 1 80px;
  min-width: 72px;
  max-width: 160px;
  height: 6px;
  accent-color: var(--hw-accent, #8e6e53);
  cursor: pointer;
}

#saju-widget-host .saju-birth-wrap {
  width: 100%;
  box-sizing: border-box;
}
/* 페이지 레이아웃: .saju-calc overflow-x 로 달력 포커스 링 우측이 잘리는 경우 */
#saju-widget-host[data-saju-layout="page"] .saju-birth-wrap {
  padding-right: 8px;
}
#saju-widget-host .saju-birth-text {
  font-size: 16px; /* 모바일 줌 방지 */
}

/* 상담 입력창 줌 방지 - 모바일 */
#saju-widget-host #chat-input {
  font-size: 16px !important;
  min-height: 36px;
  padding-top: 6px;
  padding-bottom: 6px;
}
#saju-widget-host #chat-send {
  min-height: 36px;
  padding-top: 6px !important;
  padding-bottom: 6px !important;
}
#saju-widget-host.saju-chat-visible .saju-mini-btn,
#saju-widget-host.saju-chat-visible .saju-btn {
  opacity: 1;
}
#saju-widget-host #chat-input::placeholder {
  font-size: 14px;
}

#saju-widget-host .chat-msg{
  display: flex !important;
}

/* 봇: 프로필·이름(말풍선 밖) + 본문 말풍선 */
#saju-widget-host .chat-msg:not(.me) {
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 4px;
  max-width: 100%;
}

#saju-widget-host .chat-bot-identity {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  padding: 0 2px;
  max-width: 100%;
}

#saju-widget-host .chat-bot-identity .chat-bubble-header {
  margin: 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-msg:not(.me) .chat-bubble {
  max-width: min(92%, 100%);
}

/* 봇 프로필·이름 — 말풍선 밖 identity 줄 */
#saju-widget-host .chat-bubble-header{
  font-weight: 800;
  font-size: 12px;
  opacity: .75;
  line-height: 1.2;
  margin: 0;
}
/* 프로필 없이 이름만 (동일 타이포 비율) */
#saju-widget-host .chat-bubble-header--no-photo{
  display: flex;
  align-items: flex-end;
  gap: 6px;
  flex-wrap: nowrap;
  font-weight: 600;
  opacity: 1;
}
#saju-widget-host .chat-bubble-header--with-avatar{
  display: flex;
  align-items: flex-end; /* 프로필·이름 하단 맞춤 */
  gap: 3px;
  flex-wrap: nowrap;
  font-weight: 600;
  opacity: 1;
}
/* 프로필 원형 래퍼 — 이름은 사진 바깥(.chat-bubble-bot-name) */
#saju-widget-host .chat-bubble-avatar-wrap{
  position: relative;
  width: var(--chat-bot-avatar-size);
  height: var(--chat-bot-avatar-size);
  max-width: var(--chat-bot-avatar-size);
  min-width: 0; /* flex: 이미지 고유 너비로 래퍼가 늘어나는 것 방지 */
  flex-shrink: 0;
}
#saju-widget-host .chat-bubble-avatar{
  display: block;
  /* % 대신 고정 px — 부모가 flex일 때 intrinsic 크기로 폭이 커지는 현상 방지 */
  width: var(--chat-bot-avatar-size, 36px);
  height: var(--chat-bot-avatar-size, 36px);
  max-width: var(--chat-bot-avatar-size, 36px);
  max-height: var(--chat-bot-avatar-size, 36px);
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(0,0,0,.08);
  box-sizing: border-box;
}
/* 예전 마크업: 래퍼 없이 헤더에 img만 있는 경우 */
#saju-widget-host .chat-bubble-header--with-avatar > .chat-bubble-avatar{
  width: 36px;
  height: 36px;
  max-width: 36px;
  max-height: 36px;
}
/* 사진 옆 이름 — 프로필 직경 대비 약 1/3 (36px → 12px) */
#saju-widget-host .chat-bubble-bot-name{
  flex-shrink: 0;
  font-size: calc(var(--chat-bot-avatar-size) / 3);
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: inherit;
  opacity: .88;
  white-space: nowrap;
}

#saju-widget-host .chat-bubble-body{
    margin: 0;
    padding: 0;
}
#saju-widget-host .chat-bubble-body:has(.saju-teaser-gate) {
    overflow: visible;
}

/* 첫 턴 종합 리포트(제한 마크다운: # / ## / ###) */
#saju-widget-host .chat-bubble-body .saju-md-title {
    font-size: 1.05rem;
    font-weight: 800;
    margin: 0 0 0.45rem;
    line-height: 1.35;
    color: var(--hw-ink, #2d2926);
    letter-spacing: -0.02em;
}
#saju-widget-host .chat-bubble-body .saju-md-h2 {
    font-size: 0.98rem;
    font-weight: 700;
    margin: 0.85rem 0 0.35rem;
    line-height: 1.35;
    color: var(--hw-ink, #2d2926);
    letter-spacing: -0.02em;
}
#saju-widget-host .chat-bubble-body .saju-md-h2:first-child {
    margin-top: 0;
}
#saju-widget-host .chat-bubble-body .saju-md-h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0.55rem 0 0.2rem;
    line-height: 1.35;
    color: var(--hw-accent-dim, #6b5542);
    letter-spacing: -0.02em;
}
#saju-widget-host .chat-bubble-body .saju-md-p {
    margin: 0 0 0.55rem;
    line-height: 1.55;
    word-break: keep-all;
}

/* 봇 답변 줄 단위 표시(스트리밍 효과) */
#saju-widget-host .chat-bubble-body--streaming .chat-stream-line{
    animation: sajuChatLineIn 0.16s ease-out;
    margin: 0;
}
#saju-widget-host .chat-bubble-body--streaming .chat-stream-line--empty{
    min-height: 0.55em;
    line-height: 1.4;
}
@keyframes sajuChatLineIn{
    from { opacity: 0; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce){
    #saju-widget-host .chat-bubble-body--streaming .chat-stream-line{
        animation: none;
    }
}

/* 게스트 티저: 앞 구간 선명, 나머지는 말풍선 안에서 전체 노출 + 블러(높이로 잘리지 않음) */
#saju-widget-host .saju-teaser-visible {
    margin: 0;
    padding: 0;
}
#saju-widget-host .saju-teaser-gate {
    position: relative;
    margin-top: 0.35rem;
}
#saju-widget-host .saju-teaser-blur {
    position: relative;
    user-select: none;
    pointer-events: none;
    overflow: visible;
    isolation: isolate;
}
/* 선명 구간 → 블러 구간 경계만 부드럽게 */
#saju-widget-host .saju-teaser-blur::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 1.25rem;
    z-index: 2;
    pointer-events: none;
    background: linear-gradient(
        to bottom,
        #fff 0%,
        rgba(255, 255, 255, 0.72) 45%,
        transparent 100%
    );
}
#saju-widget-host .saju-teaser-blur-inner {
    position: relative;
    z-index: 0;
    margin: 0;
    padding: 0.15rem 0 0.35rem;
    line-height: 1.55;
    filter: blur(3.5px);
    -webkit-filter: blur(3.5px);
    opacity: 0.93;
}
#saju-widget-host .saju-teaser-blur-block {
    margin: 0 0 0.75em;
    padding: 0;
}
#saju-widget-host .saju-teaser-blur-block:last-child {
    margin-bottom: 0;
}
#saju-widget-host .saju-teaser-cta {
    margin: 0.85rem 0 0;
    padding: 0;
    text-align: center;
}
#saju-widget-host .saju-teaser-cta__button {
    display: block;
    box-sizing: border-box;
    width: 100%;
    padding: 12px 14px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.05);
    color: #2d2926;
    opacity: 1;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.45;
    text-align: center;
    text-decoration: none;
    word-break: keep-all;
}
#saju-widget-host .saju-teaser-cta__button:hover,
#saju-widget-host .saju-teaser-cta__button:focus-visible {
    background: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.1);
    color: #1c1612;
    opacity: 1;
    outline: none;
}
#saju-widget-host .chat-guest-initial-login,
#saju-widget-host .chat-guest-continue-login,
#saju-widget-host .chat-tokens-continue {
    display: flex;
    justify-content: flex-end;
    margin: 10px 0 6px;
    padding: 0 2px;
}
#saju-widget-host .chat-guest-initial-login .saju-teaser-cta__button,
#saju-widget-host .chat-guest-continue-login .saju-teaser-cta__button,
#saju-widget-host .chat-tokens-continue .saju-teaser-cta__button {
    width: auto;
    max-width: min(280px, 100%);
}
#saju-widget-host .chat-guest-continue-login .saju-teaser-cta__button,
#saju-widget-host .chat-tokens-continue .saju-teaser-cta__button {
    max-width: none;
    white-space: nowrap;
}
@media (min-width: 769px) {
    #saju-widget-host .chat-guest-continue-login .saju-guest-continue-break {
        display: none;
    }
}

#saju-widget-host a.saju-chat-login-cta{
    display: inline-block;
    margin-top: 2px;
    font-size: 13px;
    font-weight: 700;
    color: var(--hw-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}
#saju-widget-host a.saju-chat-login-cta:hover{
    color: var(--hw-accent-dim);
}

#saju-widget-host .saju-chat-initial-report-retry__button{
    appearance: none;
    border: 1px solid var(--hw-accent);
    border-radius: 999px;
    background: var(--hw-accent);
    color: #fff;
    padding: 8px 14px;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
#saju-widget-host .saju-chat-initial-report-retry__button:hover,
#saju-widget-host .saju-chat-initial-report-retry__button:focus-visible{
    background: var(--hw-accent-dim);
    border-color: var(--hw-accent-dim);
    outline: none;
}

/* 사용자: 오른쪽 정렬 + 회색 배경 */
#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;
  }
  
  #saju-widget-host.is-open {
    right: 12px;
    margin: 0;
  }

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

  /* 본문 전용: 모바일 백드롭·우측 고정 무시 */
  #saju-widget-host[data-saju-layout="page"] {
    right: auto;
  }
  #saju-widget-host[data-saju-layout="page"].is-open #saju-widget-backdrop {
    display: none !important;
    pointer-events: none !important;
  }
}

/* ── [saju_chat_page] 본문 인라인: 플로팅 해제, 패널을 본문 폭에 맞춤 ── */

.saju-chat-page-wrap {
  width: 100%;
  max-width: min(720px, 100%);
  margin: 0 auto 2.5rem;
  box-sizing: border-box;
}

#saju-widget-host[data-saju-layout="page"] {
  position: relative !important;
  inset: auto !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  top: auto !important;
  z-index: 1;
  width: 100%;
  max-width: 100%;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

#saju-widget-host[data-saju-layout="page"] .saju-launcher-stack {
  display: none !important;
}

#saju-widget-host[data-saju-layout="page"] #saju-widget-backdrop {
  display: none !important;
  pointer-events: none !important;
}

#saju-widget-host[data-saju-layout="page"] #saju-close {
  display: none;
}

#saju-widget-host[data-saju-layout="page"] #saju-widget {
  /* 본문 삽입: 최초 뷰포트 높이(--saju-page-vh) 고정 — 인앱 브라우저 하단바 토글 시 흔들림 방지 */
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  height: min(calc(var(--saju-page-vh, 100svh) * 0.8), 720px);
  max-height: min(calc(var(--saju-page-vh, 100svh) * 0.8), 720px);
  margin-bottom: 0;
  box-sizing: border-box;
}

#saju-widget-host[data-saju-layout="page"] .saju-header {
  flex-shrink: 0;
}

#saju-widget-host[data-saju-layout="page"] .saju-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: 10px;
  padding-bottom: 25px;
}

#saju-widget-host[data-saju-layout="page"] .saju-calc {
  flex: 0 0 auto;
  min-height: auto;
  overflow: visible;
  display: flex;
  flex-direction: column;
}

#saju-widget-host[data-saju-layout="page"] .saju-character-card-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#saju-widget-host[data-saju-layout="page"] .saju-character-card-grid > :last-child:nth-child(odd) {
  grid-column: auto;
}

#saju-widget-host[data-saju-layout="page"] .saju-chat {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  flex-direction: column;
}

#saju-widget-host[data-saju-layout="page"] .chat-log {
  flex: 1 1 auto;
  min-height: 12rem;
  height: auto !important;
  max-height: none;
}

#saju-widget-host[data-saju-layout="page"] .chat-meta,
#saju-widget-host[data-saju-layout="page"] .chat-input-row {
  flex-shrink: 0;
}

#saju-widget-host[data-saju-layout="page"] .chat-font-scale-row {
  width: 100%;
  max-width: 100%;
  margin-top: 10px;
}

#saju-widget-host[data-saju-layout="page"] #saju-gochat-wrap {
  width: 100%;
  max-width: 100%;
  margin-top: 12px;
  padding: 0 0 4px;
}

#saju-widget-host[data-saju-layout="page"] .saju-help:last-of-type {
  flex-shrink: 0;
  margin-top: 8px;
}

@media (max-width: 768px) {
  .saju-chat-page-wrap {
    margin-bottom: 1.75rem;
  }

  #saju-widget-host[data-saju-layout="page"] #saju-widget {
    height: min(calc(var(--saju-page-vh, 100svh) * 0.8), 720px);
    max-height: min(calc(var(--saju-page-vh, 100svh) * 0.8), 720px);
  }

  #saju-widget-host[data-saju-layout="page"] .chat-log {
    min-height: 10rem;
    max-height: none;
  }

  #saju-widget-host[data-saju-layout="page"] .saju-character-card-grid {
    grid-template-columns: 1fr;
  }

  .saju-character-card__recommend {
    padding: 4px 10px;
    font-size: 20px;
  }

  .saju-character-card__tag {
    font-size: 11px;
  }

  .saju-character-card .saju-btn {
    font-size: 16px;
  }

  #saju-widget-host .chat-guest-continue-login .saju-teaser-cta__button,
  #saju-widget-host .chat-tokens-continue .saju-teaser-cta__button {
    max-width: min(280px, 100%);
    white-space: normal;
  }
}

/* 상담 화면도 계산기와 같은 상자. 영상 비율로 세로를 늘리지 않는다. */
#saju-widget-host.saju-chat-visible #saju-widget {
  width: calc(100vw - 24px);
  max-width: min(360px, calc(100vw - 12px));
  height: min(92vh, 720px);
  max-height: min(92vh, 720px);
  aspect-ratio: auto;
  background: #fff;
}
#saju-widget-host.saju-chat-visible[data-saju-layout="page"] #saju-widget {
  width: 100%;
  max-width: 100%;
  height: min(calc(var(--saju-page-vh, 100svh) * 0.8), 720px);
  max-height: min(calc(var(--saju-page-vh, 100svh) * 0.8), 720px);
  aspect-ratio: auto;
  margin-inline: 0;
  align-self: stretch;
}
@media (max-width: 480px) {
  #saju-widget-host.saju-chat-visible:not([data-saju-layout="page"]) #saju-widget {
    width: calc(100vw - 24px);
    max-width: 340px;
  }
}

/* 채팅 중에는 제목 대신 과거 상담·새 상담. 계산 화면에서는 제목만 보인다. */
#saju-widget-host.saju-chat-visible:not([data-saju-auth="guest"]) .saju-header .title > .dot,
#saju-widget-host.saju-chat-visible:not([data-saju-auth="guest"]) #saju-title {
  display: none;
}

#saju-widget-host:not(.saju-chat-visible) #saju-history-toggle,
#saju-widget-host:not(.saju-chat-visible) #saju-new-session-btn,
#saju-widget-host:not(.saju-chat-visible) #saju-compatibility-toggle {
  display: none;
}

.saju-mini-btn.saju-chat-toolbar__past {
  font-weight: 500;
}

.saju-mini-btn.saju-chat-toolbar__new {
  font-weight: 600;
}

.saju-header .saju-mini-btn.saju-chat-toolbar__compatibility {
  font-weight: 600;
}

.saju-compatibility-state {
  display: inline;
  margin-left: 3px;
  color: #77716b;
  font-size: inherit;
  font-weight: 800;
}

.saju-compatibility-state.is-on {
  color: inherit;
}

.saju-mini-btn.saju-chat-toolbar__compatibility.is-saved {
  border-color: var(--hw-accent, #8e6e53);
  background: var(--hw-accent, #8e6e53);
  color: #ffffff;
}

#saju-widget-host button.saju-mini-btn.saju-chat-toolbar__compatibility.is-saved:hover,
#saju-widget-host button.saju-mini-btn.saju-chat-toolbar__compatibility.is-saved:focus-visible {
  border-color: var(--hw-accent, #8e6e53);
  background: var(--hw-accent, #8e6e53);
  color: #ffffff;
}

.saju-history-panel {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  background: var(--hw-cream, #f6f4f1);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.saju-history-panel[hidden] {
  display: none !important;
}

.saju-history-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.65);
}

.saju-history-panel__title {
  font-weight: 700;
  font-size: calc(14px * var(--saju-chat-font-scale, 1));
  color: var(--hw-ink, #2d2926);
}

.saju-history-panel__body {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.saju-compatibility-panel__body {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 16px 14px 18px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-x: none;
  touch-action: pan-y;
}

.saju-compatibility-panel,
.saju-compatibility-panel__body .saju-grid,
.saju-compatibility-panel__body .saju-row {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.saju-compatibility-panel__intro {
  margin: 0 0 14px;
  color: #5d5651;
  font-size: calc(12px * var(--saju-chat-font-scale, 1));
  line-height: 1.55;
}

.saju-compatibility-panel__birth {
  grid-column: span 2;
}

.saju-compatibility-panel__time {
  display: flex;
  gap: 8px;
}

.saju-compatibility-panel__time .saju-select {
  flex: 1 1 0;
  min-width: 0;
}

.saju-compatibility-panel .saju-actions {
  margin-top: 14px;
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap;
}

.saju-compatibility-panel .saju-actions .saju-btn {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.saju-compatibility-panel .saju-help {
  margin-top: 10px;
}

@media (max-width: 480px) {
  .saju-compatibility-panel__body .saju-grid {
    grid-template-columns: 1fr;
  }

  .saju-compatibility-panel__birth {
    grid-column: auto;
  }

  .saju-compatibility-panel .saju-actions {
    flex-wrap: wrap;
  }

  .saju-compatibility-panel .saju-actions .saju-btn {
    flex: 1 1 calc(50% - 4px);
  }
}

/* 달력 바로 아래: 최근 질문 요약(탭 세션당 1회 로드) — 대화 글자 크기와 동일 배율 */
.saju-history-worry {
  flex: 0 0 auto;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.55);
  font-size: calc(12px * var(--saju-chat-font-scale, 1));
  line-height: 1.55;
  color: #3d3835;
}

.saju-history-worry[hidden] {
  display: none !important;
}

.saju-history-worry__text {
  margin: 0;
  font-weight: 600;
  color: #2d2926;
}

.saju-history-worry__loading {
  margin: 0;
  color: #666;
  font-style: italic;
}

.saju-history-worry__empty {
  margin: 0;
  color: #777;
}

.saju-history-calendar {
  flex: 0 0 auto;
  padding: 8px 10px 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.45);
}

.saju-history-calendar[hidden] {
  display: none !important;
}

.saju-history-cal__nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.saju-history-cal__title {
  font-size: calc(13px * var(--saju-chat-font-scale, 1));
  font-weight: 700;
  color: var(--hw-ink, #2d2926);
}

.saju-history-cal__nav-btn {
  padding: 4px 10px;
  font: inherit;
  font-size: calc(12px * var(--saju-chat-font-scale, 1));
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
  color: #444;
  cursor: pointer;
}

.saju-history-cal__nav-btn:hover,
.saju-history-cal__nav-btn:focus-visible {
  border-color: rgba(142, 110, 83, 0.45);
  outline: none;
}

.saju-history-cal__weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 4px;
  font-size: calc(10px * var(--saju-chat-font-scale, 1));
  font-weight: 600;
  color: #888;
  text-align: center;
}

.saju-history-cal__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.saju-history-cal__pad {
  min-height: 30px;
}

.saju-history-cal__day {
  position: relative;
  min-height: 30px;
  padding: 2px 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  font: inherit;
  font-size: calc(12px * var(--saju-chat-font-scale, 1));
  color: #333;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
}

.saju-history-cal__day:disabled {
  cursor: default;
  color: #ccc;
}

.saju-history-cal__day:not(:disabled):hover,
.saju-history-cal__day:not(:disabled):focus-visible {
  background: rgba(142, 110, 83, 0.12);
  outline: none;
}

.saju-history-cal__day.is-today {
  font-weight: 700;
  color: var(--hw-accent, #8e6e53);
}

.saju-history-cal__day.is-muted {
  color: #bbb;
}

.saju-history-cal__day.has-sessions {
  font-weight: 600;
}

.saju-history-cal__day.is-selected {
  background: rgba(142, 110, 83, 0.22);
  box-shadow: inset 0 0 0 1px rgba(142, 110, 83, 0.45);
}

.saju-history-cal__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--hw-accent, #8e6e53);
  opacity: 0.85;
}

.saju-history-cal__filter-hint {
  font-size: calc(11px * var(--saju-chat-font-scale, 1));
  color: #666;
  margin: 0 0 6px;
  padding: 0 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.saju-history-cal__clear {
  border: none;
  background: none;
  font: inherit;
  font-size: calc(11px * var(--saju-chat-font-scale, 1));
  color: var(--hw-accent, #8e6e53);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.saju-history-cal__clear:hover,
.saju-history-cal__clear:focus-visible {
  color: #6a5240;
  outline: none;
}

.saju-history-list {
  flex: 0 0 auto;
  overflow: visible;
  padding: 8px;
  min-height: 0;
}

/* 각 상담 카드: 우측 상단 × 로 삭제 (본문 클릭은 상담 열기) */
.saju-history-item-row {
  position: relative;
  margin-bottom: 6px;
}

.saju-history-item {
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  text-align: left;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 10px 36px 10px 12px;
  margin-bottom: 0;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.saju-history-item__character {
  display: flex;
  flex: 0 0 66px;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.saju-history-item__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  overflow: hidden;
  border: 1px solid rgba(142, 110, 83, 0.2);
  border-radius: 50%;
  background: var(--hw-cream, #f7f2ea);
  color: var(--hw-ink);
  font-size: 9px;
  font-weight: 800;
}

.saju-history-item__avatar--sukja {
  border-color: rgba(170, 104, 77, 0.24);
  background: #ead3c1;
  color: #704a38;
}

.saju-history-item__avatar--cheoneul {
  border-color: rgba(92, 64, 32, 0.45);
  background: #2a2118;
  color: #f3e6d4;
}

.saju-history-item__avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.saju-history-item__character-name {
  max-width: 100%;
  color: #4d4540;
  font-size: calc(10px * var(--saju-chat-font-scale, 1));
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  word-break: keep-all;
}

.saju-history-item__content {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.saju-history-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 28px;
  height: 28px;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  font: inherit;
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  color: #6a5240;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.saju-history-delete:hover,
.saju-history-delete:focus-visible {
  color: #8a3c32;
  border-color: rgba(180, 80, 70, 0.4);
  background: rgba(255, 245, 243, 0.98);
  outline: none;
}

.saju-history-item:hover,
.saju-history-item:focus-visible {
  border-color: rgba(142, 110, 83, 0.4);
  outline: none;
}

.saju-history-item.is-current {
  border-color: rgba(142, 110, 83, 0.55);
  box-shadow: 0 2px 10px rgba(45, 41, 38, 0.08);
}

.saju-history-item__date {
  font-size: calc(12px * var(--saju-chat-font-scale, 1));
  font-weight: 700;
  color: var(--hw-accent, #8e6e53);
}

.saju-history-item__preview {
  font-size: calc(12px * var(--saju-chat-font-scale, 1));
  line-height: 1.45;
  color: #444;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.saju-history-loading,
.saju-history-empty {
  padding: 16px 12px;
  font-size: calc(13px * var(--saju-chat-font-scale, 1));
  color: #666;
  text-align: center;
}
