#chat-entry, #chat-dialog {
  --chat-right: max(16px, env(safe-area-inset-right));
  --chat-bottom: max(16px, env(safe-area-inset-bottom));
  box-sizing: border-box;
  font: 16px/1.5 "Noto Sans KR", system-ui, sans-serif;
}

#chat-entry {
  position: fixed;
  text-decoration: none;
  right: var(--chat-right);
  bottom: var(--chat-bottom);
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid #fff;
  border-radius: 24px;
  background: #1a365d;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 3px 12px rgb(15 36 66 / 22%);
}
#chat-entry::before {
  content: "";
  width: 16px;
  height: 13px;
  border: 2px solid currentColor;
  border-radius: 7px 7px 7px 1px;
}
#chat-entry:hover { background: #0f2442; }

#chat-dialog {
  position: fixed;
  inset: auto var(--chat-right) var(--chat-bottom) auto;
  margin: 0;
  width: min(440px, calc(100% - var(--chat-right) - max(12px, env(safe-area-inset-left))));
  height: min(680px, calc(100dvh - var(--chat-bottom) - max(12px, env(safe-area-inset-top))));
  max-height: calc(100% - 24px);
  padding: 0;
  border: 1px solid #dde3ea;
  border-radius: 12px;
  color: #1c2836;
  background: #fff;
}
#chat-dialog[open] { display: flex; flex-direction: column; }
#chat-dialog::backdrop { background: rgb(15 36 66 / 50%); }
#chat-dialog .chat-toolbar { display: flex; align-items: center; gap: 12px; padding: 4px 12px; border-bottom: 1px solid #dde3ea; }
#chat-dialog strong { margin-right: auto; }
#chat-dialog a, #chat-dialog button { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; }
#chat-dialog a { color: #1f5fae; text-decoration: underline; }
#chat-dialog button { padding: 0 8px; border: 0; background: transparent; color: #1c2836; cursor: pointer; }
#chat-dialog iframe {
  /* Keep the embedded conversation in flow despite the legacy floating-widget rule. */
  position: static !important;
  flex: 1;
  min-height: 0;
  width: 100%;
  border: 0;
}

#chat-entry:focus-visible, #chat-dialog :is(a, button):focus-visible {
  outline: 3px solid #2670b9;
  outline-offset: 2px;
}

@media screen {
  body:has(> #chat-entry) { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
}
@media print {
  #chat-entry, #chat-dialog { display: none; }
}
