/* Bottom-right customer chat widget and inline chat triggers */
.ki-chat-widget {
  --ki-chat-ink: #17212c;
  --ki-chat-muted: #5b6674;
  --ki-chat-line: #ddd6c4;
  --ki-chat-surface: #fffefb;
  --ki-chat-soft: #f7f5ef;
  --ki-chat-accent: #eeba30;
  --ki-chat-accent-soft: #fff7df;
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 12000;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ki-chat-ink);
  pointer-events: none;
}

.ki-chat-widget *,
.ki-chat-widget *::before,
.ki-chat-widget *::after {
  box-sizing: border-box;
}

.ki-chat-launcher,
.ki-chat-panel,
.ki-chat-panel button,
.ki-chat-panel textarea,
.ki-chat-panel a {
  font: inherit;
}

.ki-chat-launcher,
.ki-chat-inline-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 7px 14px 7px 8px;
  border: 1px solid rgba(238, 186, 48, .85);
  border-radius: 8px;
  background: #fff;
  color: #17212c;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .10);
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  font-weight: 400;
}

.ki-chat-launcher {
  pointer-events: auto;
}

.ki-chat-inline-trigger {
  margin: 4px 0 26px;
}

.ki-chat-launcher:hover,
.ki-chat-launcher:focus-visible,
.ki-chat-inline-trigger:hover,
.ki-chat-inline-trigger:focus-visible {
  outline: none;
  background: var(--ki-chat-accent-soft);
}

.ki-chat-launcher-mark,
.ki-chat-inline-trigger-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: var(--ki-chat-accent);
  color: #17212c;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.ki-chat-launcher-text {
  font-size: 14px;
  font-weight: 400;
  white-space: nowrap;
}

.ki-chat-panel {
  pointer-events: auto;
  display: none;
  width: min(420px, calc(100vw - 24px));
  max-height: min(680px, calc(100vh - 34px));
  overflow: hidden;
  border: 1px solid var(--ki-chat-line);
  border-radius: 8px;
  background: var(--ki-chat-surface);
  box-shadow: 0 12px 30px rgba(15, 23, 42, .12);
  position: relative;
}

.ki-chat-widget.is-open .ki-chat-launcher {
  display: none;
}

.ki-chat-widget.is-open .ki-chat-panel {
  display: grid;
  grid-template-rows: auto minmax(170px, 1fr) auto auto auto;
}

.ki-chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--ki-chat-line);
  background: linear-gradient(180deg, var(--ki-chat-accent-soft) 0%, #ffffff 100%);
}

.ki-chat-title,
.ki-chat-header span {
  display: block;
}

.ki-chat-title {
  margin-bottom: 2px;
  color: var(--ki-chat-ink);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.15;
}

.ki-chat-header span {
  color: var(--ki-chat-muted);
  font-size: 12px;
  line-height: 1.35;
}

.ki-chat-close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid var(--ki-chat-line);
  border-radius: 8px;
  background: #fff;
  color: var(--ki-chat-ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}

.ki-chat-messages {
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
  min-height: 210px;
  padding: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.ki-chat-message {
  width: min(100%, 345px);
  padding: 10px 11px;
  border: 1px solid var(--ki-chat-line);
  border-radius: 8px;
  background: #fff;
  color: var(--ki-chat-ink);
  font-size: 13px;
  line-height: 1.42;
}

.ki-chat-message.user {
  justify-self: end;
  border-color: rgba(238, 186, 48, .65);
  background: #fff1bf;
}

.ki-chat-question {
  margin-bottom: 4px;
  color: var(--ki-chat-ink);
  font-size: 13px;
  font-weight: 500;
}

.ki-chat-message p {
  margin: 7px 0 0;
  color: inherit;
}

.ki-chat-message p:first-child {
  margin-top: 0;
}

.ki-chat-meta {
  margin-top: 7px;
  color: var(--ki-chat-muted);
  font-size: 11px;
  font-weight: 400;
}

.ki-chat-quick {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 10px 12px 0;
  border-top: 1px solid var(--ki-chat-line);
  background: #fff;
}

.ki-chat-quick button {
  flex: 0 0 auto;
  max-width: 235px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--ki-chat-line);
  border-radius: 8px;
  background: #fff;
  color: var(--ki-chat-ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 400;
  text-align: left;
  white-space: nowrap;
}

.ki-chat-quick button:hover,
.ki-chat-quick button:focus-visible {
  outline: none;
  border-color: rgba(238, 186, 48, .75);
  background: var(--ki-chat-accent-soft);
}

.ki-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px 12px 12px;
  background: #fff;
}

.ki-chat-form textarea {
  min-height: 44px;
  max-height: 120px;
  resize: vertical;
  padding: 8px 10px;
  border: 1px solid var(--ki-chat-line);
  border-radius: 8px;
  background: #fff;
  color: var(--ki-chat-ink);
  line-height: 1.35;
}

.ki-chat-form textarea:focus {
  outline: 2px solid rgba(238, 186, 48, .45);
  border-color: var(--ki-chat-accent);
}

.ki-chat-form button {
  min-height: 44px;
  padding: 0 13px;
  border: 0;
  border-radius: 8px;
  background: var(--ki-chat-accent);
  color: #17212c;
  cursor: pointer;
  font-weight: 700;
}


.ki-chat-action-row {
  margin-top: 10px;
}

.ki-chat-action {
  min-height: 36px;
  padding: 8px 11px;
  border: 1px solid rgba(238, 186, 48, .8);
  border-radius: 8px;
  background: var(--ki-chat-accent);
  color: var(--ki-chat-ink);
  cursor: pointer;
  font-weight: 700;
}

.ki-chat-overlay[hidden] {
  display: none;
}

.ki-chat-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  align-items: end;
  padding: 12px;
  background: rgba(23, 33, 44, .18);
}

.ki-chat-overlay-card {
  display: grid;
  gap: 9px;
  max-height: 100%;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--ki-chat-line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 30px rgba(15, 23, 42, .16);
}

.ki-chat-overlay-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.ki-chat-overlay-title {
  color: var(--ki-chat-ink);
  font-size: 15px;
  font-weight: 700;
}

.ki-chat-overlay-head span,
.ki-chat-overlay-card label span,
.ki-chat-overlay-status {
  color: var(--ki-chat-muted);
  font-size: 12px;
}

.ki-chat-overlay-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--ki-chat-line);
  border-radius: 8px;
  background: #fff;
  color: var(--ki-chat-ink);
  cursor: pointer;
}

.ki-chat-overlay-card label {
  display: grid;
  gap: 4px;
}

.ki-chat-overlay-card input,
.ki-chat-overlay-card textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 9px;
  border: 1px solid var(--ki-chat-line);
  border-radius: 8px;
  color: var(--ki-chat-ink);
}

.ki-chat-hidden {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.ki-chat-overlay-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ki-chat-overlay-actions button {
  min-height: 40px;
  border: 1px solid var(--ki-chat-line);
  border-radius: 8px;
  background: #fff;
  color: var(--ki-chat-ink);
  cursor: pointer;
  font-weight: 700;
}

.ki-chat-overlay-actions button[type="submit"] {
  border-color: rgba(238, 186, 48, .85);
  background: var(--ki-chat-accent);
}

.ki-chat-contact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  justify-content: flex-start;
  padding: 10px 12px;
  border-top: 1px solid var(--ki-chat-line);
  background: linear-gradient(180deg, var(--ki-chat-accent-soft) 0%, #ffffff 100%);
  font-size: 12px;
  font-weight: 400;
}

.ki-chat-contact a {
  color: var(--ki-chat-ink);
  text-decoration: none;
}

body .scroll-top {
  bottom: 88px;
}

@media (max-width: 620px) {
  .ki-chat-widget {
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    left: max(10px, env(safe-area-inset-left));
  }

  .ki-chat-launcher {
    margin-left: auto;
  }

  .ki-chat-panel {
    width: 100%;
    max-height: calc(100vh - 22px);
  }

  .ki-chat-widget.is-open .ki-chat-panel {
    grid-template-rows: auto minmax(150px, 1fr) auto auto auto;
  }

  .ki-chat-form {
    grid-template-columns: 1fr;
  }

  .ki-chat-launcher-text,
  .ki-chat-inline-trigger span:last-child {
    white-space: normal;
  }

  body .scroll-top {
    right: 12px;
    bottom: 78px;
  }
}