/* Public chat: isolated from the page, with room above the mobile contact bar. */
.hk-chat {
  --hk-chat-green: #153b32;
  --hk-chat-green-hover: #245446;
  --hk-chat-ivory: #fffefb;
  --hk-chat-gold: #be9a57;
  --hk-chat-ink: #19362e;
  --hk-chat-muted: #586b61;
  --hk-chat-line: #dfdfd2;
  color: var(--hk-chat-ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.6;
}

.hk-chat *, .hk-chat *::before, .hk-chat *::after { box-sizing: border-box; }
.hk-chat [hidden] { display: none !important; }
.hk-chat :is(button, input, textarea, a) { font: inherit; touch-action: manipulation; }
.hk-chat :is(button, a) { -webkit-tap-highlight-color: transparent; }
.hk-chat :is(button, input, textarea, a):focus-visible {
  outline: 3px solid var(--hk-chat-gold);
  outline-offset: 3px;
}
.hk-chat :is(button, input, textarea, a):disabled {
  cursor: wait;
  opacity: .65;
}

.hk-chat .hk-chat-launcher {
  position: fixed;
  z-index: 35;
  right: 24px;
  bottom: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 56px;
  min-height: 56px;
  max-width: calc(100vw - 48px);
  padding: 12px 20px;
  border: 1px solid #be9a5770;
  border-radius: 999px;
  background: var(--hk-chat-green);
  color: var(--hk-chat-ivory);
  box-shadow: 0 5px 16px #153b3226, 0 16px 40px #153b321f;
  font-weight: 650;
  font-size: .93em;
  line-height: 1.5;
  cursor: pointer;
  transition: background-color .16s ease, box-shadow .16s ease;
}
.hk-chat .hk-chat-launcher:hover { background: var(--hk-chat-green-hover); box-shadow: 0 8px 24px #153b3233; }
.hk-chat .hk-chat-launcher svg { width: 24px; height: 24px; flex: 0 0 24px; }
.hk-chat .hk-chat-launcher span { min-width: 0; overflow-wrap: anywhere; }

.hk-chat .hk-chat-panel {
  position: fixed;
  inset: auto 24px 92px auto;
  width: 390px;
  max-width: calc(100vw - 24px);
  height: min(620px, calc(100dvh - 48px));
  max-height: calc(100dvh - 116px);
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #d2d8cb;
  border-radius: 22px;
  background: var(--hk-chat-ivory);
  color: var(--hk-chat-ink);
  box-shadow: 0 12px 32px #132b2624, 0 32px 80px #132b261f;
  font: inherit;
  overscroll-behavior: contain;
}
.hk-chat .hk-chat-panel[open] { display: flex; flex-direction: column; }
.hk-chat .hk-chat-panel::backdrop { background: #0e251a40; }

.hk-chat .hk-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  gap: 12px;
  padding: 17px 18px 15px;
  background: var(--hk-chat-green);
  color: var(--hk-chat-ivory);
  border-bottom: 1px solid #be9a5766;
}
.hk-chat .hk-chat-header > div { min-width: 0; }
.hk-chat .hk-chat-title { margin: 0; font-size: 1.04em; font-weight: 700; line-height: 1.55; overflow-wrap: anywhere; }
.hk-chat .hk-chat-presence {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 3px 0 0;
  color: #dce7dd;
  font-size: .77em;
  line-height: 1.6;
}
.hk-chat .hk-chat-presence::before {
  content: "";
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  margin-top: 6px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: #adc0b2;
}
.hk-chat .hk-chat-presence[data-online="true"]::before { background: #99d6a7; border-color: #b9e3c2; }
.hk-chat .hk-chat-presence[data-online="false"]::before { background: transparent; border-color: #becebf; }
.hk-chat .hk-chat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 8px;
  border: 1px solid #e1e8db40;
  border-radius: 12px;
  background: #ffffff0a;
  color: inherit;
  line-height: 1;
  cursor: pointer;
}
.hk-chat .hk-chat-icon:hover { background: #ffffff1a; }
.hk-chat .hk-chat-icon svg { width: 20px; height: 20px; }

.hk-chat .hk-chat-alert {
  flex: 0 0 auto;
  max-height: 120px;
  margin: 10px 14px 0;
  padding: 10px 12px;
  overflow: auto;
  border: 1px solid #d8c49e;
  border-radius: 10px;
  background: #faf4e8;
  color: #62491d;
  font-size: .82em;
  line-height: 1.65;
  overflow-wrap: anywhere;
  overscroll-behavior: contain;
}
.hk-chat .hk-chat-alert[data-tone="error"] { background: #fff3ef; border-color: #dca79a; color: #862f21; }
.hk-chat .hk-chat-alert[data-tone="success"] { background: #edf5ec; border-color: #b2c9b4; color: #254d30; }

.hk-chat .hk-chat-messages {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  padding: 20px 16px;
  overflow-y: auto;
  overflow-x: hidden;
  background: #f8f7f1;
  scrollbar-width: thin;
  scrollbar-color: #b8c3b6 transparent;
  overscroll-behavior: contain;
  scroll-padding: 16px;
}
.hk-chat .hk-chat-empty {
  margin: auto;
  padding: 12px 6px;
  max-width: 28ch;
  color: var(--hk-chat-muted);
  font-size: .88em;
  line-height: 1.85;
  text-align: center;
  overflow-wrap: anywhere;
}
.hk-chat .hk-chat-message {
  flex: 0 0 auto;
  align-self: flex-start;
  width: fit-content;
  max-width: 91%;
  min-width: 0;
  padding: 11px 13px 9px;
  border: 1px solid #dce2d7;
  border-radius: 15px 15px 15px 4px;
  background: var(--hk-chat-ivory);
  color: var(--hk-chat-ink);
  box-shadow: 0 2px 5px #153b3205;
}
.hk-chat .hk-chat-message--guest {
  align-self: flex-end;
  border-color: #153b32;
  border-radius: 15px 15px 4px 15px;
  background: var(--hk-chat-green);
  color: var(--hk-chat-ivory);
}
.hk-chat .hk-chat-message--staff { border-color: #d6ddcf; }
.hk-chat .hk-chat-body { margin: 0; font-size: .9em; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal; }
.hk-chat .hk-chat-meta { display: block; margin-top: 5px; color: var(--hk-chat-muted); font-size: .69em; line-height: 1.6; overflow-wrap: anywhere; }
.hk-chat .hk-chat-message--guest .hk-chat-meta { color: #d2e0d6; }

.hk-chat .hk-chat-form {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 14px 16px 12px;
  border-top: 1px solid var(--hk-chat-line);
  background: var(--hk-chat-ivory);
}
.hk-chat .hk-chat-field { display: block; min-width: 0; margin: 0; color: var(--hk-chat-ink); font-size: .82em; font-weight: 600; line-height: 1.55; }
.hk-chat .hk-chat-field :is(input, textarea) { margin-top: 5px; }
.hk-chat :is(.hk-chat-form input, .hk-chat-form textarea) {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #aab8a7;
  border-radius: 10px;
  background: #ffffff;
  color: var(--hk-chat-ink);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.65;
  box-shadow: inset 0 1px 2px #153b3205;
}
.hk-chat .hk-chat-form textarea { height: 86px; max-height: 120px; resize: none; overflow-y: auto; overscroll-behavior: contain; }
.hk-chat .hk-chat-form :is(input, textarea)::placeholder { color: #66796b; opacity: 1; }
.hk-chat .hk-chat-form :is(input, textarea):focus-visible { border-color: var(--hk-chat-green); outline-offset: 2px; }
.hk-chat .hk-chat-form [aria-invalid="true"] { border-color: #a84330; }
.hk-chat .hk-chat-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.hk-chat .hk-chat-count { min-width: 0; color: var(--hk-chat-muted); font-size: .72em; line-height: 1.6; overflow-wrap: anywhere; }
.hk-chat .hk-chat-submit {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 9px 18px;
  border: 1px solid var(--hk-chat-green);
  border-radius: 10px;
  background: var(--hk-chat-green);
  color: var(--hk-chat-ivory);
  font-size: .88em;
  font-weight: 650;
  line-height: 1.5;
  cursor: pointer;
  transition: background-color .16s ease;
}
.hk-chat .hk-chat-submit:hover { background: var(--hk-chat-green-hover); }
.hk-chat .hk-chat-submit svg { width: 18px; height: 18px; }
.hk-chat .hk-chat-retry { display: flex; flex: 0 0 auto; justify-content: flex-end; gap: 8px; padding: 0 16px 8px; }

.hk-chat .hk-chat-footer {
  flex: 0 0 auto;
  min-width: 0;
  padding: 10px 16px 12px;
  border-top: 1px solid #e9e7dc;
  background: #fcfbf6;
}
.hk-chat .hk-chat-privacy { margin: 0; color: var(--hk-chat-muted); font-size: .72em; line-height: 1.7; overflow-wrap: anywhere; }
.hk-chat .hk-chat-extras { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; min-width: 0; margin-top: 4px; }
.hk-chat :is(.hk-chat-secondary, .hk-chat-link) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #285141;
  font-size: .76em;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.hk-chat .hk-chat-secondary:hover { border-color: #d0d9ca; background: #edf2e9; }
.hk-chat .hk-chat-link { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: #829883; }
.hk-chat .hk-chat-link:hover { background: #edf2e9; text-decoration-color: currentColor; }

@media (max-width: 639px) {
  .hk-chat .hk-chat-launcher { right: 12px; bottom: calc(86px + env(safe-area-inset-bottom, 0px)); max-width: calc(100vw - 24px); min-height: 52px; padding: 11px 16px; }
  .hk-chat .hk-chat-panel {
    right: 12px;
    bottom: calc(86px + env(safe-area-inset-bottom, 0px));
    width: 390px;
    max-width: calc(100vw - 24px);
    height: min(600px, calc(100dvh - 120px));
    max-height: calc(100dvh - 110px - env(safe-area-inset-bottom, 0px));
    border-radius: 18px;
  }
  .hk-chat .hk-chat-header { padding: 14px 14px 12px; }
  .hk-chat .hk-chat-messages { padding: 16px 12px; }
  .hk-chat .hk-chat-form { padding: 12px; }
  .hk-chat .hk-chat-footer { padding: 8px 12px 10px; }
  .hk-chat .hk-chat-message { max-width: 94%; }
}

/* On short viewports, each necessary section can scroll within the dialog. */
@media (max-height: 620px) {
  .hk-chat .hk-chat-header { padding-block: 9px; }
  .hk-chat .hk-chat-messages { min-height: 64px; padding-block: 12px; }
  .hk-chat .hk-chat-alert { flex-shrink: 1; min-height: 0; max-height: 64px; margin-top: 6px; padding-block: 6px; }
  .hk-chat .hk-chat-form { flex-shrink: 1; min-height: 0; max-height: 46%; overflow-y: auto; overscroll-behavior: contain; gap: 7px; padding-block: 9px; }
  .hk-chat .hk-chat-form textarea { height: 64px; }
  .hk-chat .hk-chat-footer { flex-shrink: 1; min-height: 0; max-height: 100px; overflow-y: auto; overscroll-behavior: contain; padding-block: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .hk-chat *, .hk-chat *::before, .hk-chat *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media (forced-colors: active) {
  .hk-chat .hk-chat-panel { border: 1px solid CanvasText; box-shadow: none; }
  .hk-chat .hk-chat-panel::backdrop { background: transparent; }
  .hk-chat :is(.hk-chat-launcher, .hk-chat-submit, .hk-chat-icon, .hk-chat-secondary) { border: 1px solid ButtonText; background: ButtonFace; color: ButtonText; box-shadow: none; }
  .hk-chat :is(.hk-chat-header, .hk-chat-footer, .hk-chat-messages, .hk-chat-message, .hk-chat-alert) { background: Canvas; color: CanvasText; border-color: CanvasText; box-shadow: none; }
  .hk-chat :is(.hk-chat-presence, .hk-chat-meta, .hk-chat-count, .hk-chat-privacy) { color: CanvasText; }
  .hk-chat .hk-chat-presence::before { background: CanvasText; border-color: CanvasText; }
  .hk-chat .hk-chat-presence[data-online="false"]::before { background: Canvas; }
  .hk-chat .hk-chat-link { color: LinkText; text-decoration-color: LinkText; }
  .hk-chat :is(button, input, textarea, a):focus-visible { outline-color: Highlight; }
}
