:root {
  --koperia-chat-bg: #0d1b2a;
  --koperia-chat-primary: #1f7a8c;
  --koperia-chat-action: #31cdcf;
  --koperia-chat-accent: #39d98a;
  --koperia-chat-text: #15202b;
  --koperia-chat-muted: #667085;
  --koperia-chat-panel: #ffffff;
  --koperia-chat-border: rgba(13, 27, 42, 0.12);
}

.koperia-chat-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 2147483000;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.koperia-chat-button {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 999px;
  padding: 12px 24px 12px 12px;
  background: linear-gradient(135deg, var(--koperia-chat-bg), var(--koperia-chat-primary));
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 16px 40px rgba(13, 27, 42, 0.22);
  cursor: pointer;
}

.koperia-chat-button-avatar {
  position: relative;
  display: inline-flex;
  width: 48px;
  height: 48px;
  border-radius: 18px;
  overflow: visible;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.22), 0 8px 22px rgba(13, 27, 42, 0.22);
}

.koperia-chat-button-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  border-radius: 18px;
  transform: scale(1.08);
}

.koperia-chat-button-dot {
  position: absolute;
  right: -4px;
  top: -4px;
  width: 14px;
  height: 14px;
  border-radius: 99px;
  background: var(--koperia-chat-accent);
  border: 3px solid #fff;
  box-shadow: 0 0 0 5px rgba(57, 217, 138, 0.16);
  animation: koperiaDotPulse 1.8s infinite ease-in-out;
}

@keyframes koperiaDotPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 5px rgba(57, 217, 138, 0.14);
  }
  50% {
    transform: scale(1.18);
    box-shadow: 0 0 0 9px rgba(57, 217, 138, 0.05);
  }
}

.koperia-chat-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(430px, calc(100vw - 28px));
  height: min(640px, calc(100vh - 96px));
  margin-bottom: 12px;
  border-radius: 22px;
  overflow: hidden;
  background: var(--koperia-chat-panel);
  color: var(--koperia-chat-text);
  box-shadow: 0 26px 86px rgba(13, 27, 42, 0.34), 0 0 28px rgba(49, 205, 207, 0.16);
  border: 1px solid rgba(49, 205, 207, 0.7);
  transform-origin: bottom right;
  animation: koperiaPanelIn .28s ease-out;
}

.koperia-chat-panel[hidden] {
  display: none !important;
}

.koperia-chat-root.is-open .koperia-chat-button {
  display: none !important;
}

@keyframes koperiaPanelIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.koperia-chat-header {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 24px 18px 18px;
  background: linear-gradient(135deg, var(--koperia-chat-bg), var(--koperia-chat-primary));
  color: #fff;
  overflow: visible;
}

.koperia-chat-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.koperia-chat-avatar {
  position: relative;
  flex: 0 0 auto;
  width: 62px;
  height: 62px;
  border-radius: 22px;
  overflow: visible;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25), 0 14px 34px rgba(13, 27, 42, 0.24);
}

.koperia-chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  border-radius: 22px;
  transform: scale(1.08);
}

.koperia-chat-avatar-status {
  position: absolute;
  right: -5px;
  top: -5px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--koperia-chat-accent);
  border: 3px solid #fff;
  box-shadow: 0 0 0 5px rgba(57, 217, 138, 0.16);
  animation: koperiaDotPulse 1.8s infinite ease-in-out;
}

.koperia-chat-header strong,
.koperia-chat-header span {
  display: block;
}

.koperia-chat-header strong {
  font-size: 17px;
}

.koperia-chat-header span {
  opacity: .85;
  font-size: 13px;
}

.koperia-chat-close {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 99px;
  border: 1px solid rgba(255,255,255,.28);
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  position: relative;
  z-index: 3;
}

.koperia-chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  overflow-y: auto;
  padding: 16px;
  background: #f7fafc;
}

.koperia-chat-message {
  max-width: 86%;
  margin: 0 0 10px;
  padding: 11px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.35;
  white-space: pre-wrap;
}

.koperia-chat-message.bot {
  background: #fff;
  border: 1px solid var(--koperia-chat-border);
  border-top-left-radius: 6px;
}

.koperia-chat-message.bot a {
  color: #0057ff;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.koperia-chat-message.bot a:hover {
  color: #003fc2;
}

.koperia-chat-message.typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: auto;
  min-width: 54px;
  min-height: 39px;
}

.koperia-chat-message.typing span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--koperia-chat-muted);
  opacity: .35;
  animation: koperiaTypingPulse 1.05s infinite ease-in-out;
}

.koperia-chat-message.typing span:nth-child(2) {
  animation-delay: .16s;
}

.koperia-chat-message.typing span:nth-child(3) {
  animation-delay: .32s;
}

@keyframes koperiaTypingPulse {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: .35;
  }
  40% {
    transform: translateY(-4px);
    opacity: .9;
  }
}

.koperia-chat-message.user {
  margin-left: auto;
  background: var(--koperia-chat-primary);
  color: #fff;
  border-top-right-radius: 6px;
}

.koperia-chat-form {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  align-items: stretch;
  padding: 14px 14px 12px;
  border-top: 1px solid rgba(49, 205, 207, 0.24);
  background: #fff;
}

.koperia-chat-form textarea {
  flex: 1;
  display: block;
  resize: none;
  border: 1px solid var(--koperia-chat-border);
  border-radius: 14px;
  padding: 15px 13px;
  font: inherit;
  font-size: 14px;
  min-height: 72px;
  height: 72px;
  line-height: 20px;
  box-sizing: border-box;
  overflow-y: auto;
}

.koperia-chat-form button {
  align-self: stretch;
  border: 0;
  border-radius: 14px;
  padding: 0 18px;
  background: var(--koperia-chat-action);
  color: #001014;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0 22px rgba(49, 205, 207, 0.35);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}

.koperia-chat-form button:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 32px rgba(49, 205, 207, 0.55);
  filter: brightness(1.04);
}

.koperia-chat-form button:disabled {
  opacity: .55;
  cursor: wait;
}

.koperia-chat-privacy {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 14px 12px;
  font-size: 11px;
  color: var(--koperia-chat-muted);
  background: #fff;
}

@media (max-width: 520px) {
  body.koperia-chat-open .site-header,
  body.koperia-chat-open header.site-header,
  body.koperia-chat-open .main-header,
  body.koperia-chat-open header[role="banner"] {
    display: none !important;
  }

  .koperia-chat-root {
    right: 0;
    bottom: 0;
  }

  .koperia-chat-button {
    padding: 11px 21px 11px 11px;
    font-size: 17px;
    box-shadow: 0 18px 42px rgba(13, 27, 42, 0.26);
  }

  .koperia-chat-panel {
    position: fixed;
    inset: 0;
    z-index: 2147483001;
    width: 100vw;
    height: 100dvh;
    margin-bottom: 0;
    border-radius: 0;
    border: 0;
    box-shadow: none;
    animation: none;
  }

  .koperia-chat-header {
    padding-top: calc(22px + env(safe-area-inset-top, 0px));
  }

  .koperia-chat-form {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .koperia-chat-privacy {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
}
