.hk-chat-root {
  --chat-accent: #e00821;
  --chat-accent-hover: #b3061a;
  --chat-navy: #1f3347;
  --chat-navy-mid: #2a4a65;
  --chat-text: #1d1d1f;
  --chat-muted: #5f6065;
  --chat-border: rgba(31, 51, 71, .14);
  --chat-surface: #fff;
  --chat-soft: #f8f8fa;
  position: fixed;
  right: max(1.25rem, env(safe-area-inset-right, 0px));
  bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
  z-index: 999;
  font-family: 'Satoshi', sans-serif;
  color: var(--chat-text);
}

.hk-chat-root[aria-hidden="true"] {
  display: none;
}

.hk-chat__launcher {
  min-width: 154px;
  min-height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .65rem;
  padding: .75rem 1.1rem;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 10px;
  background: var(--chat-navy);
  color: #fff;
  box-shadow: 0 14px 38px rgba(31, 51, 71, .26);
  font-size: .92rem;
  font-weight: 700;
  line-height: 1.2;
  transition: transform .2s ease, background .2s ease, box-shadow .2s ease;
}

.hk-chat__launcher:hover {
  background: var(--chat-navy-mid);
  transform: translateY(-2px);
  box-shadow: 0 18px 46px rgba(31, 51, 71, .3);
}

.hk-chat__launcher:active {
  transform: translateY(0);
}

.hk-chat__launcher svg,
.hk-chat__send svg,
.hk-chat__close svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.hk-chat__launcher-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #62d890;
  box-shadow: 0 0 0 3px rgba(98, 216, 144, .18);
}

.hk-chat__panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + .8rem);
  width: min(390px, calc(100vw - 2rem));
  height: min(620px, calc(100dvh - 7.5rem));
  min-height: 470px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--chat-border);
  border-radius: 16px 16px 4px 16px;
  background: var(--chat-surface);
  box-shadow: 0 24px 70px rgba(19, 35, 51, .24);
  transform-origin: bottom right;
}

.hk-chat__panel[hidden] {
  display: none;
}

.hk-chat__header {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: .8rem;
  padding: 1rem;
  overflow: hidden;
  background: linear-gradient(135deg, var(--chat-navy), #172a3d);
  color: #fff;
}

.hk-chat__header::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .2;
  background-image: linear-gradient(rgba(255, 255, 255, .18) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .18) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-mask-image: linear-gradient(90deg, #000, transparent 80%);
  mask-image: linear-gradient(90deg, #000, transparent 80%);
}

.hk-chat__mark,
.hk-chat__identity,
.hk-chat__close {
  position: relative;
  z-index: 1;
}

.hk-chat__mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 8px;
  background: rgba(255, 255, 255, .08);
  font-family: 'Teko', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: .06em;
}

.hk-chat__title {
  margin: 0;
  color: #fff;
  font-family: 'Teko', sans-serif;
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.hk-chat__status {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin: .3rem 0 0;
  color: rgba(255, 255, 255, .78);
  font-size: .72rem;
  line-height: 1.25;
}

.hk-chat__status::before {
  content: '';
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #62d890;
}

.hk-chat__close,
.hk-chat__send {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
}

.hk-chat__close {
  color: #fff;
  background: rgba(255, 255, 255, .08);
}

.hk-chat__close:hover {
  background: rgba(255, 255, 255, .16);
}

.hk-chat__conversation {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem;
  background: var(--chat-soft);
  scrollbar-color: rgba(31, 51, 71, .3) transparent;
}

.hk-chat__messages {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.hk-chat__message {
  max-width: 88%;
  padding: .75rem .9rem;
  border: 1px solid var(--chat-border);
  border-radius: 4px 12px 12px 12px;
  background: #fff;
  color: var(--chat-text);
  font-size: .9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 2px 8px rgba(31, 51, 71, .04);
}

.hk-chat__message--user {
  align-self: flex-end;
  border-color: var(--chat-navy);
  border-radius: 12px 4px 12px 12px;
  background: var(--chat-navy);
  color: #fff;
}

.hk-chat__typing {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  min-width: 60px;
}

.hk-chat__typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chat-muted);
  animation: hk-chat-pulse 1.1s infinite ease-in-out;
}

.hk-chat__typing span:nth-child(2) { animation-delay: .12s; }
.hk-chat__typing span:nth-child(3) { animation-delay: .24s; }

@keyframes hk-chat-pulse {
  0%, 60%, 100% { opacity: .35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

.hk-chat__quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin-top: .85rem;
}

.hk-chat__quick-actions[hidden] {
  display: none;
}

.hk-chat__quick-action {
  min-height: 44px;
  padding: .55rem .75rem;
  border: 1px solid rgba(31, 51, 71, .24);
  border-radius: 8px;
  background: #fff;
  color: var(--chat-navy);
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.2;
}

.hk-chat__quick-action:hover {
  border-color: var(--chat-accent);
  color: var(--chat-accent-hover);
}

.hk-chat__composer {
  padding: .8rem;
  border-top: 1px solid var(--chat-border);
  background: #fff;
}

.hk-chat__input-label {
  display: block;
  margin: 0 0 .35rem;
  color: var(--chat-navy);
  font-size: .72rem;
  font-weight: 700;
}

.hk-chat__input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: .5rem;
}

.hk-chat__input {
  width: 100%;
  min-height: 48px;
  max-height: 96px;
  resize: none;
  padding: .72rem .8rem;
  border: 1px solid rgba(31, 51, 71, .25);
  border-radius: 8px;
  background: #fff;
  color: var(--chat-text);
  font-size: 16px;
  line-height: 1.4;
}

.hk-chat__input::placeholder {
  color: #6b6b70;
}

.hk-chat__input:focus {
  border-color: var(--chat-navy);
  box-shadow: 0 0 0 3px rgba(31, 51, 71, .1);
}

.hk-chat__send {
  min-width: 48px;
  min-height: 48px;
  background: var(--chat-accent);
  color: #fff;
}

.hk-chat__send:hover {
  background: var(--chat-accent-hover);
}

.hk-chat__send:disabled,
.hk-chat__quick-action:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.hk-chat__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-top: .55rem;
  color: var(--chat-muted);
  font-size: .67rem;
  line-height: 1.35;
}

.hk-chat__meta a {
  color: var(--chat-navy);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.hk-chat__meta-contact {
  white-space: nowrap;
}

.hk-chat-root :focus-visible {
  outline: 2px solid var(--chat-navy);
  outline-offset: 3px;
}

.hk-chat__header :focus-visible,
.hk-chat__send:focus-visible,
.hk-chat__launcher:focus-visible {
  outline-color: #fff;
}

body.has-hk-chat .back-to-top {
  bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 480px) {
  .hk-chat-root {
    right: max(.75rem, env(safe-area-inset-right, 0px));
    bottom: max(.75rem, env(safe-area-inset-bottom, 0px));
  }

  .hk-chat__launcher {
    min-width: 142px;
    min-height: 52px;
  }

  .hk-chat__panel {
    position: fixed;
    inset: calc(var(--nav-height, 80px) + .5rem) .5rem calc(4.6rem + env(safe-area-inset-bottom, 0px));
    width: auto;
    height: auto;
    min-height: 0;
    border-radius: 12px 12px 4px 12px;
  }

  .hk-chat__message { max-width: 92%; }
  .hk-chat__meta {
    flex-direction: column;
    align-items: flex-start;
    gap: .25rem;
  }
  .hk-chat__meta-contact { white-space: normal; }
  body.has-hk-chat .back-to-top { bottom: calc(4.8rem + env(safe-area-inset-bottom, 0px)); }
}

@media (max-height: 620px) and (min-width: 481px) {
  .hk-chat__panel {
    height: calc(100dvh - 5.5rem);
    min-height: 0;
  }
}

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

@media print {
  .hk-chat-root { display: none !important; }
}
