:root {
  --tekta-chat-ink: #121110;
  --tekta-chat-panel: #191817;
  --tekta-chat-paper: #f7f5ef;
  --tekta-chat-muted: #aaa59c;
  --tekta-chat-red: #d7262e;
  --tekta-chat-line: rgba(255, 255, 255, 0.12);
}

.tekta-chat,
.tekta-chat * {
  box-sizing: border-box;
}

.tekta-chat {
  position: fixed;
  z-index: 1000;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  color: var(--tekta-chat-paper);
  font-family: "DM Sans", "Inter", sans-serif;
  transition: opacity 160ms ease, transform 160ms ease;
}

.tekta-chat--page-form-active {
  pointer-events: none;
  opacity: 0;
  transform: translateY(10px);
}

.tekta-chat__launcher {
  position: relative;
  display: grid;
  width: 62px;
  height: 62px;
  padding: 0;
  place-items: center;
  overflow: hidden;
  color: #fff;
  background: var(--tekta-chat-ink);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.3), 5px 5px 0 var(--tekta-chat-red);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.tekta-chat__launcher::after {
  content: "";
  position: absolute;
  inset: auto -14px -22px auto;
  width: 54px;
  height: 54px;
  background: var(--tekta-chat-red);
  border-radius: 50%;
}

.tekta-chat__launcher:hover {
  transform: translateY(-3px);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.34), 5px 7px 0 var(--tekta-chat-red);
}

.tekta-chat__launcher:active {
  transform: translateY(1px);
}

.tekta-chat__launcher svg {
  position: relative;
  z-index: 1;
  width: 29px;
  height: 29px;
}

.tekta-chat__pulse {
  position: absolute;
  z-index: 2;
  top: 7px;
  right: 7px;
  width: 10px;
  height: 10px;
  background: #53d489;
  border: 2px solid var(--tekta-chat-ink);
  border-radius: 50%;
}

.tekta-chat__window {
  position: absolute;
  right: 0;
  bottom: 78px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(390px, calc(100vw - 32px));
  height: min(640px, calc(100svh - 118px));
  overflow: hidden;
  background: var(--tekta-chat-panel);
  border: 1px solid var(--tekta-chat-line);
  border-radius: 22px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42), 7px 7px 0 var(--tekta-chat-red);
  opacity: 0;
  transform: translateY(14px) scale(0.97);
  transform-origin: right bottom;
  visibility: hidden;
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
}

.tekta-chat--open .tekta-chat__window {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
}

.tekta-chat--open .tekta-chat__launcher {
  visibility: hidden;
}

.tekta-chat__header {
  position: relative;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 11px;
  align-items: center;
  padding: 16px 16px 15px;
  background: var(--tekta-chat-ink);
  border-bottom: 1px solid var(--tekta-chat-line);
}

.tekta-chat__header::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--tekta-chat-red);
}

.tekta-chat__mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #fff;
  background: var(--tekta-chat-red);
  border-radius: 12px 4px 12px 4px;
  font-family: "Archivo Black", sans-serif;
  font-size: 1.05rem;
  letter-spacing: -0.08em;
}

.tekta-chat__identity strong,
.tekta-chat__identity span {
  display: block;
}

.tekta-chat__identity strong {
  font-family: "Archivo Black", sans-serif;
  font-size: 0.98rem;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.tekta-chat__identity span {
  margin-top: 2px;
  color: var(--tekta-chat-muted);
  font-size: 0.75rem;
}

.tekta-chat__close {
  display: grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  color: var(--tekta-chat-paper);
  background: transparent;
  border: 1px solid var(--tekta-chat-line);
  border-radius: 10px;
  cursor: pointer;
}

.tekta-chat__close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.tekta-chat__messages {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 16px 12px;
  background:
    linear-gradient(rgba(25, 24, 23, 0.94), rgba(25, 24, 23, 0.98)),
    repeating-linear-gradient(135deg, transparent 0 18px, rgba(255, 255, 255, 0.025) 18px 19px);
  scrollbar-color: #4d4945 transparent;
  scrollbar-width: thin;
}

.tekta-chat__message {
  width: fit-content;
  max-width: 86%;
  margin: 0 0 12px;
  padding: 11px 13px;
  color: var(--tekta-chat-paper);
  background: #2b2926;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px 15px 15px 15px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.tekta-chat__message--user {
  margin-left: auto;
  color: #fff;
  background: var(--tekta-chat-red);
  border-color: transparent;
  border-radius: 15px 4px 15px 15px;
}

.tekta-chat__message--error {
  color: #ffd6d8;
  border-color: rgba(215, 38, 46, 0.55);
}

.tekta-chat__typing::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 1em;
  margin-left: 4px;
  vertical-align: -2px;
  background: var(--tekta-chat-red);
  animation: tekta-chat-caret 850ms steps(1) infinite;
}

.tekta-chat__quick-actions {
  display: flex;
  gap: 7px;
  margin: 2px 0 14px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tekta-chat__quick-actions::-webkit-scrollbar {
  display: none;
}

.tekta-chat__quick-action {
  flex: 0 0 auto;
  padding: 8px 10px;
  color: var(--tekta-chat-paper);
  background: transparent;
  border: 1px solid rgba(215, 38, 46, 0.65);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.tekta-chat__quick-action:hover {
  background: rgba(215, 38, 46, 0.15);
}

.tekta-chat__composer {
  padding: 12px;
  background: var(--tekta-chat-ink);
  border-top: 1px solid var(--tekta-chat-line);
}

.tekta-chat__form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: end;
}

.tekta-chat__input {
  width: 100%;
  min-height: 44px;
  max-height: 108px;
  resize: none;
  padding: 11px 12px;
  color: var(--tekta-chat-paper);
  background: #272522;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  outline: none;
  font: inherit;
  font-size: 0.88rem;
  line-height: 1.4;
}

.tekta-chat__input::placeholder {
  color: #858078;
}

.tekta-chat__input:focus {
  border-color: var(--tekta-chat-red);
  box-shadow: 0 0 0 3px rgba(215, 38, 46, 0.14);
}

.tekta-chat__send {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  color: #fff;
  background: var(--tekta-chat-red);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}

.tekta-chat__send:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.tekta-chat__send svg {
  width: 19px;
  height: 19px;
}

.tekta-chat__note {
  margin: 7px 2px 0;
  color: #77726b;
  font-size: 0.66rem;
  text-align: center;
}

.tekta-chat button:focus-visible,
.tekta-chat textarea:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

@keyframes tekta-chat-caret {
  50% { opacity: 0; }
}

@media (max-width: 560px) {
  .tekta-chat {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .tekta-chat__launcher {
    width: 56px;
    height: 56px;
    border-radius: 16px;
  }

  .tekta-chat__window {
    position: fixed;
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    width: calc(100vw - max(20px, env(safe-area-inset-right) + env(safe-area-inset-left)));
    height: min(590px, calc(100svh - max(20px, env(safe-area-inset-top) + env(safe-area-inset-bottom))));
    max-height: 72svh;
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.48), 4px 4px 0 var(--tekta-chat-red);
  }

  .tekta-chat__messages {
    padding: 15px 13px 8px;
  }

  .tekta-chat__composer {
    padding: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tekta-chat *,
  .tekta-chat *::before,
  .tekta-chat *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
