:root {
  --kia-ink: #081426;
  --kia-blue: #146be8;
  --kia-blue-dark: #0b4eae;
  --kia-yellow: #ffc928;
  --kia-paper: #ffffff;
  --kia-soft: #f3f7fc;
  --kia-line: #dce5f0;
  --kia-muted: #617086;
}

.kia-chat-launcher {
  position: fixed;
  right: 20px;
  bottom: 82px;
  z-index: 120;
  min-height: 58px;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 8px;
  padding: 12px 13px 12px 17px;
  color: #fff;
  background: var(--kia-ink);
  box-shadow: 0 18px 48px rgba(8, 20, 38, .3);
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.kia-chat-launcher:hover {
  transform: translateY(-2px);
  background: #102442;
  box-shadow: 0 22px 58px rgba(8, 20, 38, .38);
}

.kia-chat-launcher-copy {
  display: grid;
  gap: 2px;
  text-align: left;
}

.kia-chat-launcher-copy strong {
  color: #fff;
  font-size: 14px;
  line-height: 1.1;
}

.kia-chat-launcher-copy small {
  color: rgba(255, 255, 255, .64);
  font-size: 10px;
  font-weight: 700;
}

.kia-chat-launcher-arrow {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--kia-ink);
  background: var(--kia-yellow);
  font-size: 17px;
  font-weight: 950;
}

.kia-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 150;
  width: min(450px, calc(100vw - 40px));
  height: min(720px, calc(100vh - 40px));
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  visibility: hidden;
  border: 1px solid rgba(220, 229, 240, .92);
  border-radius: 8px;
  background: var(--kia-paper);
  box-shadow: 0 32px 100px rgba(8, 20, 38, .38);
  opacity: 0;
  transform: translateY(18px) scale(.97);
  transform-origin: right bottom;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease, visibility .2s;
}

.kia-chat-panel.open {
  visibility: visible;
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.kia-chat-head {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 17px 18px;
  color: #fff;
  background: var(--kia-ink);
  border-bottom: 3px solid var(--kia-blue);
  box-shadow: inset 5px 0 0 var(--kia-yellow);
}

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

.kia-chat-agent-copy {
  min-width: 0;
}

.kia-chat-brand {
  margin: 0 0 5px !important;
  color: var(--kia-yellow) !important;
  font-size: 9px !important;
  font-weight: 950 !important;
  text-transform: uppercase;
}

.kia-chat-agent strong,
.kia-chat-agent span {
  display: block;
}

.kia-chat-agent strong {
  font-size: 19px;
  line-height: 1.15;
}

.kia-chat-agent span {
  margin-top: 4px;
  color: rgba(255, 255, 255, .65);
  font-size: 11px;
  font-weight: 650;
}

.kia-chat-status {
  display: inline-flex !important;
  align-items: center;
  gap: 5px;
  margin-top: 6px !important;
  color: #9ee6bd !important;
  font-size: 10px !important;
  font-weight: 850 !important;
}

.kia-chat-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #30d17d;
}

.kia-chat-close {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, .17);
  border-radius: 6px;
  color: #fff;
  background: rgba(255, 255, 255, .08);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  transition: background .15s ease;
}

.kia-chat-close:hover {
  background: rgba(255, 255, 255, .16);
}

.kia-chat-body {
  overflow-y: auto;
  padding: 19px;
  background:
    linear-gradient(rgba(255, 255, 255, .78), rgba(255, 255, 255, .78)),
    linear-gradient(90deg, transparent 23px, rgba(20, 107, 232, .04) 24px),
    linear-gradient(transparent 23px, rgba(20, 107, 232, .04) 24px);
  background-color: var(--kia-soft);
  background-size: auto, 24px 24px, 24px 24px;
  overscroll-behavior: contain;
  scrollbar-color: #b9c8da transparent;
  scrollbar-width: thin;
}

.kia-welcome {
  margin-bottom: 14px;
  border: 1px solid var(--kia-line);
  border-left: 4px solid var(--kia-blue);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 8px 24px rgba(8, 20, 38, .06);
}

.kia-welcome-label {
  display: block;
  margin-bottom: 6px;
  color: var(--kia-blue-dark);
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
}

.kia-welcome p {
  margin: 0;
  color: #263952;
  font-size: 13px;
  line-height: 1.55;
}

.kia-message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}

.kia-message-row.user {
  justify-content: flex-end;
}

.kia-message-dot {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(20, 107, 232, .3);
  border-radius: 5px;
  color: #fff;
  background: var(--kia-blue);
  box-shadow: inset 0 -3px 0 rgba(8, 20, 38, .12);
  font-size: 10px;
  font-weight: 950;
}

.kia-message {
  width: fit-content;
  max-width: 84%;
  border: 1px solid var(--kia-line);
  border-radius: 8px 8px 8px 2px;
  padding: 11px 13px;
  color: #1c304a;
  background: #fff;
  box-shadow: 0 5px 16px rgba(8, 20, 38, .05);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.kia-message.user {
  border-color: var(--kia-blue);
  border-radius: 8px 8px 2px 8px;
  color: #fff;
  background: var(--kia-blue);
  box-shadow: 0 8px 20px rgba(20, 107, 232, .18);
}

.kia-message.system {
  width: 100%;
  max-width: 100%;
  border-color: #f0d271;
  border-radius: 8px;
  color: #6b4a00;
  background: #fff8dc;
  box-shadow: none;
  font-size: 11px;
}

.kia-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 58px;
}

.kia-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8297b0;
  animation: kia-pulse 1s infinite ease-in-out;
}

.kia-typing i:nth-child(2) { animation-delay: .15s; }
.kia-typing i:nth-child(3) { animation-delay: .3s; }

@keyframes kia-pulse {
  0%, 100% { opacity: .28; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-2px); }
}

.kia-quick-title {
  width: 100%;
  margin: 3px 0 2px;
  color: var(--kia-muted);
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
}

.kia-quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 16px;
}

.kia-quick {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--kia-line);
  border-radius: 8px;
  padding: 10px;
  color: #163354;
  background: rgba(255, 255, 255, .94);
  cursor: pointer;
  text-align: left;
  font-size: 11px;
  font-weight: 850;
  line-height: 1.25;
  transition: border-color .15s ease, transform .15s ease, background .15s ease;
}

.kia-quick:hover {
  transform: translateY(-1px);
  border-color: var(--kia-blue);
  background: #eef5ff;
}

.kia-quick:disabled {
  opacity: .48;
  cursor: not-allowed;
  transform: none;
}

.kia-quick-icon {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--kia-blue-dark);
  background: #e7f0ff;
  font-size: 13px;
  font-weight: 950;
}

.kia-quick.booking {
  grid-column: 1 / -1;
  min-height: 48px;
  border-color: #f0cd55;
  color: #493500;
  background: #fff7d6;
}

.kia-quick.booking .kia-quick-icon {
  color: #493500;
  background: var(--kia-yellow);
}

.kia-privacy-consent {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 9px;
  align-items: start;
  margin: 2px 0 4px;
  border: 1px solid var(--kia-line);
  border-radius: 8px;
  padding: 11px;
  color: #5a6b80;
  background: rgba(255, 255, 255, .96);
  font-size: 10px;
  line-height: 1.5;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.kia-privacy-consent input {
  width: 17px;
  height: 17px;
  margin: 1px 0 0;
  accent-color: var(--kia-blue);
}

.kia-privacy-consent a {
  color: var(--kia-blue-dark);
  font-weight: 850;
  text-decoration: underline;
}

.kia-privacy-consent.accepted {
  border-color: rgba(21, 155, 105, .35);
  background: #f1fbf6;
}

.kia-privacy-consent.needs-attention {
  border-color: #dc8b00;
  background: #fff7dc;
  box-shadow: 0 0 0 3px rgba(255, 201, 40, .2);
}

.kia-slot-list {
  margin: 4px 0 15px 34px;
  border: 1px solid var(--kia-line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.kia-slot-day {
  margin: 9px 0 7px;
  color: #40546d;
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
}

.kia-slot-day:first-child {
  margin-top: 0;
}

.kia-slot {
  min-width: 70px;
  min-height: 35px;
  margin: 0 5px 5px 0;
  border: 1px solid #c7d7ed;
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--kia-blue-dark);
  background: #f7faff;
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
}

.kia-slot:hover {
  border-color: var(--kia-blue);
  color: #fff;
  background: var(--kia-blue);
}

.kia-chat-compose {
  border-top: 1px solid var(--kia-line);
  padding: 12px 13px 11px;
  background: #fff;
  box-shadow: 0 -10px 30px rgba(8, 20, 38, .05);
}

.kia-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  border: 1px solid #cbd8e7;
  border-radius: 8px;
  padding: 5px;
  background: #f8fbff;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.kia-chat-form:focus-within {
  border-color: var(--kia-blue);
  box-shadow: 0 0 0 3px rgba(20, 107, 232, .1);
}

.kia-chat-input {
  width: 100%;
  min-height: 42px;
  max-height: 110px;
  resize: none;
  border: 0;
  outline: none;
  padding: 10px;
  color: var(--kia-ink);
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
}

.kia-chat-send {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 6px;
  color: var(--kia-ink);
  background: var(--kia-yellow);
  cursor: pointer;
  font-size: 20px;
  font-weight: 950;
  transition: background .15s ease, transform .15s ease;
}

.kia-chat-send:hover {
  transform: translateY(-1px);
  background: #ffd64f;
}

.kia-chat-send:disabled,
.kia-chat-input:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.kia-chat-privacy {
  margin: 8px 4px 0;
  color: #7a899c;
  font-size: 9px;
  line-height: 1.35;
}

@media (max-width: 640px) {
  .kia-chat-launcher {
    right: 12px;
    bottom: 76px;
    min-height: 54px;
  }

  .kia-chat-panel {
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border: 0;
    border-radius: 0;
    transform: translateY(18px);
  }

  .kia-chat-panel.open {
    transform: translateY(0);
  }

  .kia-chat-head {
    min-height: 86px;
    padding-top: max(14px, env(safe-area-inset-top));
  }

  .kia-chat-body {
    padding: 15px;
  }

  .kia-quick-actions {
    grid-template-columns: 1fr;
  }

  .kia-quick.booking {
    grid-column: auto;
  }

  .kia-message {
    max-width: 88%;
  }

  .kia-slot-list {
    margin-left: 0;
  }

  .kia-chat-compose {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .kia-chat-panel,
  .kia-chat-launcher,
  .kia-quick,
  .kia-chat-send {
    transition: none;
  }
}
