.tg-webchat,
.tg-webchat * {
  box-sizing: border-box;
}

.tg-webchat {
  --tg-green: #227a3d;
  --tg-mint: #e9f8ed;
  --tg-ink: #183126;
  --tg-muted: #64756c;
  --tg-border: #d9e7de;
  --tg-panel: #ffffff;
  bottom: 20px;
  color: var(--tg-ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  position: fixed;
  right: 20px;
  z-index: 2147483000;
}

.tg-webchat .tg-webchat-launcher {
  align-items: center;
  background: var(--tg-panel);
  border: 1px solid rgba(34, 122, 61, 0.22);
  border-radius: 999px;
  box-shadow: 0 14px 34px rgba(24, 49, 38, 0.22);
  cursor: pointer;
  display: flex;
  height: 64px;
  justify-content: center;
  padding: 10px;
  transition: transform 160ms ease, box-shadow 160ms ease;
  width: 64px;
}

.tg-webchat .tg-webchat-launcher:hover,
.tg-webchat .tg-webchat-launcher:focus-visible {
  box-shadow: 0 18px 42px rgba(24, 49, 38, 0.28);
  outline: 3px solid rgba(34, 122, 61, 0.18);
  transform: translateY(-2px);
}

.tg-webchat .tg-webchat-launcher img {
  display: block;
  height: 42px;
  object-fit: contain;
  width: 42px;
}

.tg-webchat .tg-webchat-panel {
  background: var(--tg-panel);
  border: 1px solid var(--tg-border);
  border-radius: 18px;
  bottom: 0;
  box-shadow: 0 22px 64px rgba(24, 49, 38, 0.24);
  display: none;
  max-height: min(700px, calc(100vh - 40px));
  overflow: hidden;
  position: absolute;
  right: 0;
  width: min(380px, calc(100vw - 32px));
}

.tg-webchat-open .tg-webchat-launcher {
  display: none;
}

.tg-webchat-open .tg-webchat-panel {
  display: flex;
  flex-direction: column;
}

.tg-webchat .tg-webchat-header {
  align-items: center;
  background: linear-gradient(135deg, #174b2a 0%, #236a3a 100%);
  color: white;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 16px;
}

.tg-webchat .tg-webchat-title-wrap {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.tg-webchat .tg-webchat-title-wrap strong {
  font-size: 16px;
  line-height: 1.2;
}

.tg-webchat .tg-webchat-title-wrap span {
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  line-height: 1.35;
}

.tg-webchat .tg-webchat-minimize {
  align-items: center;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  color: white;
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 auto;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  height: 28px;
  justify-content: center;
  line-height: 1;
  padding: 0;
  width: 28px;
}

.tg-webchat .tg-webchat-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  padding: 14px;
}

.tg-webchat .tg-webchat-prechat {
  display: grid;
  gap: 10px;
}

.tg-webchat .tg-webchat-prechat label {
  color: var(--tg-muted);
  display: grid;
  font-size: 12px;
  font-weight: 800;
  gap: 5px;
  margin: 0;
  width: 100%;
}

.tg-webchat .tg-webchat-label {
  display: inline-flex;
  gap: 3px;
  line-height: 1.2;
  min-width: 0;
}

.tg-webchat .tg-webchat-required {
  color: #d92d20;
  font-weight: 900;
}

.tg-webchat .tg-webchat-prechat input,
.tg-webchat .tg-webchat-prechat textarea,
.tg-webchat .tg-webchat-reply input {
  appearance: none;
  background: #f8fbf9;
  border: 1px solid var(--tg-border);
  border-radius: 12px;
  color: var(--tg-ink);
  display: block;
  font: inherit;
  font-size: 14px;
  line-height: 1.35;
  min-width: 0;
  outline: none;
  padding: 10px 11px;
  width: 100%;
}

.tg-webchat .tg-webchat-prechat textarea {
  min-height: 92px;
  resize: vertical;
}

.tg-webchat .tg-webchat-prechat input:focus,
.tg-webchat .tg-webchat-prechat textarea:focus,
.tg-webchat .tg-webchat-reply input:focus {
  border-color: var(--tg-green);
  box-shadow: 0 0 0 3px rgba(34, 122, 61, 0.12);
}

.tg-webchat .tg-webchat-prechat button,
.tg-webchat .tg-webchat-reply button {
  align-items: center;
  appearance: none;
  background: var(--tg-green);
  border: 0;
  border-radius: 999px;
  color: white;
  cursor: pointer;
  display: inline-flex !important;
  font: inherit;
  font-size: 14px;
  font-weight: 900;
  justify-content: center;
  line-height: 1.2;
  min-height: 42px;
  min-width: 76px;
  padding: 11px 14px;
  text-align: center;
  text-decoration: none;
  visibility: visible !important;
  white-space: nowrap;
}

.tg-webchat .tg-webchat-conversation {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 360px;
}

.tg-webchat .tg-webchat-conversation[hidden],
.tg-webchat .tg-webchat-prechat[hidden] {
  display: none;
}

.tg-webchat .tg-webchat-messages {
  background: #f3f8f5;
  border: 1px solid var(--tg-border);
  border-radius: 16px;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  min-height: 280px;
  overflow-y: auto;
  padding: 12px;
}

.tg-webchat .tg-webchat-message-row {
  display: flex;
}

.tg-webchat .tg-webchat-message-row.is-staff {
  justify-content: flex-start;
}

.tg-webchat .tg-webchat-message-row.is-visitor {
  justify-content: flex-end;
}

.tg-webchat .tg-webchat-message {
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  max-width: 82%;
  padding: 9px 11px 7px;
  white-space: pre-wrap;
  word-break: break-word;
}

.tg-webchat .tg-webchat-message-row.is-staff .tg-webchat-message {
  background: white;
  border: 1px solid var(--tg-border);
  border-bottom-left-radius: 5px;
}

.tg-webchat .tg-webchat-message-row.is-visitor .tg-webchat-message {
  background: var(--tg-green);
  border-bottom-right-radius: 5px;
  color: white;
}

.tg-webchat .tg-webchat-message-time {
  font-size: 10px;
  font-weight: 700;
  margin-top: 4px;
  opacity: 0.68;
  text-align: right;
}

.tg-webchat .tg-webchat-reply {
  align-items: center;
  display: flex;
  gap: 8px;
  margin-top: 10px;
  width: 100%;
}

.tg-webchat .tg-webchat-reply input {
  flex: 1 1 auto;
}

.tg-webchat .tg-webchat-reply button {
  flex: 0 0 auto;
}

.tg-webchat .tg-webchat-status {
  color: var(--tg-muted);
  font-size: 12px;
  font-weight: 700;
  min-height: 18px;
  padding: 8px 2px 0;
}

.tg-webchat .tg-webchat-status[data-tone="error"] {
  color: #b42318;
}

.tg-webchat .tg-webchat-status[data-tone="ok"] {
  color: var(--tg-green);
}

.tg-webchat .tg-webchat-fallback {
  align-items: center;
  border-top: 1px solid var(--tg-border);
  color: var(--tg-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 8px;
  margin-top: 8px;
  padding-top: 10px;
}

.tg-webchat .tg-webchat-fallback a {
  color: var(--tg-green);
  font-weight: 900;
  text-decoration: none;
}

.tg-webchat .tg-webchat-honeypot {
  left: -10000px !important;
  opacity: 0 !important;
  position: absolute !important;
}

@media (max-width: 640px) {
  .tg-webchat {
    bottom: 14px;
    right: 14px;
  }

  .tg-webchat-panel {
    border-radius: 18px 18px 0 0;
    bottom: -14px;
    max-height: min(720px, calc(100vh - 20px));
    right: -14px;
    width: 100vw;
  }

  .tg-webchat .tg-webchat-body {
    max-height: calc(100vh - 90px);
    overflow-y: auto;
  }
}
