:root {
  --chat-color: #3b7a27;
  --chat-hover: #2b5e1b;
  --chat-ink: #fff;
  --chat-border: #599643;
  --chat-shadow: #151e353d;
  --chat-radius: 14px;
}

@media (max-width: 980px) {
  :root {
    --chat-offset: 72px;
    --chat-safe-offset: calc(72px - 12px);
  }
}

#livechat-widget,
iframe[src^="https://livechat.jusowd4.net/widget?"] {
  position: fixed;
  z-index: 2147483000;
  right: max(24px, env(safe-area-inset-right)) !important;
  --chat-bottom: max(var(--chat-offset, 24px), calc(env(safe-area-inset-bottom) + var(--chat-safe-offset, 12px)));
  --chat-launcher-height: 52px;
}

#livechat-widget {
  font-family: inherit !important;
  bottom: var(--chat-bottom) !important;
}

#livechat-widget > button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: auto !important;
  min-width: 125px;
  height: var(--chat-launcher-height) !important;
  padding: 0 15px;
  position: relative;
  border: 1px solid var(--chat-border) !important;
  border-radius: var(--chat-radius) !important;
  background: var(--chat-color) !important;
  color: var(--chat-ink) !important;
  box-shadow: 0 6px 22px var(--chat-shadow) !important;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

#livechat-widget > button::after {
  content: "실시간 상담";
}

#livechat-widget > button[aria-expanded="true"]::after {
  content: "상담 닫기";
}

#livechat-widget > button[aria-expanded="true"] > span {
  width: 24px;
  font-size: 26px !important;
  line-height: 1 !important;
  text-align: center;
}

#livechat-widget > button:hover {
  background: var(--chat-hover) !important;
}

#livechat-widget > button:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: -5px;
}

iframe[src^="https://livechat.jusowd4.net/widget?"] {
  --chat-panel-bottom: calc(var(--chat-bottom) + var(--chat-launcher-height) + 12px);
  bottom: var(--chat-panel-bottom) !important;
  width: min(380px, calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right))) !important;
  height: min(640px, calc(100dvh - var(--chat-panel-bottom) - max(12px, env(safe-area-inset-top)))) !important;
  box-sizing: border-box;
  border: 1px solid var(--chat-border) !important;
  border-radius: var(--chat-radius) !important;
  background: #fff;
  box-shadow: 0 12px 48px var(--chat-shadow) !important;
}

iframe[src^="https://livechat.jusowd4.net/widget?"]:not([hidden]) {
  display: block;
}

#livechat-widget [hidden],
iframe[src^="https://livechat.jusowd4.net/widget?"][hidden] {
  display: none !important;
}

@media (max-width: 700px) {
  #livechat-widget,
  iframe[src^="https://livechat.jusowd4.net/widget?"] {
    right: max(16px, env(safe-area-inset-right)) !important;
  }
}

@media print {
  #livechat-widget,
  iframe[src^="https://livechat.jusowd4.net/widget?"] {
    display: none !important;
  }
}
