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

.krona-chat[hidden],
.krona-chat [hidden] {
  display: none !important;
}

.krona-chat {
  --kc-primary: #74b83a;
  --kc-accent: #ffaf3f;
  --kc-text: #263238;
  --kc-muted: #71808a;
  --kc-border: #e5e9ec;
  --kc-bg: #f5f7f8;
  position: fixed;
  right: 24px;
  bottom: 70px;
  z-index: 2147483000;
  width: auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  color: var(--kc-text);
  text-align: left;
  -webkit-font-smoothing: antialiased;
}

.krona-chat button,
.krona-chat input,
.krona-chat textarea {
  font: inherit;
}

.krona-chat button {
  -webkit-tap-highlight-color: transparent;
}

.krona-chat__launcher {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 64px;
  height: 60px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--kc-primary), var(--kc-accent));
  box-shadow: 0 12px 32px rgba(28, 43, 52, .25);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}

.krona-chat__launcher:hover,
.krona-chat__launcher:focus {
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(28, 43, 52, .3);
  outline: none;
}

.krona-chat.is-open .krona-chat__launcher {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(.92);
}

.krona-chat__launcher-icon {
  display: inline-flex;
  width: 29px;
  height: 29px;
}

.krona-chat__launcher-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.krona-chat__launcher-text {
  font-weight: 700;
  letter-spacing: .01em;
}

.krona-chat__badge {
  position: absolute;
  top: -6px;
  right: -3px;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border: 2px solid #fff;
  border-radius: 12px;
  color: #fff;
  background: #e53935;
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

.krona-chat__panel {
  position: absolute;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: 380px;
  height: 590px;
  max-height: calc(100vh - 94px);
  overflow: hidden;
  border: 1px solid rgba(25, 35, 42, .08);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 22px 65px rgba(20, 32, 40, .27);
  transform-origin: right bottom;
  animation: krona-chat-open .18s ease-out;
}

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

.krona-chat__header {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 78px;
  padding: 14px 52px 14px 17px;
  color: #fff;
  background: linear-gradient(135deg, var(--kc-primary), var(--kc-accent));
}

.krona-chat__avatar {
  display: flex;
  flex: 0 0 45px;
  align-items: center;
  justify-content: center;
  width: 45px;
  height: 45px;
  margin-right: 12px;
  border: 2px solid rgba(255,255,255,.78);
  border-radius: 50%;
  color: var(--kc-primary);
  background: #fff;
  font-size: 19px;
  font-weight: 800;
}

.krona-chat__heading {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.krona-chat__title {
  overflow: hidden;
  font-size: 16px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.krona-chat__status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  color: rgba(255,255,255,.92);
  font-size: 12px;
}

.krona-chat__status i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,.55);
}

.krona-chat__status.is-online i {
  background: #d8ffba;
  box-shadow: 0 0 0 3px rgba(216,255,186,.18);
}

.krona-chat__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(255,255,255,.14);
  font-size: 28px;
  font-weight: 300;
  line-height: 33px;
  cursor: pointer;
}

.krona-chat__close:hover,
.krona-chat__close:focus {
  background: rgba(255,255,255,.24);
  outline: none;
}

.krona-chat__loading {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 11px;
  color: var(--kc-muted);
  background: var(--kc-bg);
}

.krona-chat__spinner {
  width: 22px;
  height: 22px;
  border: 3px solid #dce2e5;
  border-top-color: var(--kc-primary);
  border-radius: 50%;
  animation: krona-chat-spin .8s linear infinite;
}

@keyframes krona-chat-spin { to { transform: rotate(360deg); } }

.krona-chat__auth {
  flex: 1;
  min-height: 0;
  padding: 20px;
  overflow-y: auto;
  background: var(--kc-bg);
}

.krona-chat__auth-intro {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 17px;
}

.krona-chat__auth-intro strong {
  font-size: 16px;
}

.krona-chat__auth-intro span {
  color: var(--kc-muted);
  font-size: 13px;
}

.krona-chat__tabs {
  display: flex;
  margin-bottom: 16px;
  padding: 4px;
  border: 1px solid var(--kc-border);
  border-radius: 12px;
  background: #fff;
}

.krona-chat__tabs button {
  flex: 1;
  padding: 9px 8px;
  border: 0;
  border-radius: 9px;
  color: var(--kc-muted);
  background: #74b83a8a;
  font-weight: 700;
  cursor: pointer;
}

.krona-chat__tabs button.is-active {
  color: #fff;
  background: var(--kc-primary);
}

.krona-chat__form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.krona-chat__form label:not(.krona-chat__agree) {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: #52616a;
  font-size: 12px;
  font-weight: 700;
}

.krona-chat__form label small {
  color: #9aa5ab;
  font-weight: 400;
}

.krona-chat__form input[type="text"],
.krona-chat__form input[type="tel"],
.krona-chat__form input[type="email"],
.krona-chat__form input[type="password"] {
  width: 100%;
  height: 43px;
  padding: 0 12px;
  border: 1px solid #d9dfe2;
  border-radius: 10px;
  color: var(--kc-text);
  background: #fff;
  font-size: 14px;
  font-weight: 400;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.krona-chat__form input:focus {
  border-color: var(--kc-accent);
  box-shadow: 0 0 0 3px rgba(255, 175, 63, .17);
}

.krona-chat__form label.has-error input {
  border-color: #e53935;
}

.krona-chat__agree {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: #6b7981;
  font-size: 12px;
  font-weight: 400;
  cursor: pointer;
}

.krona-chat__agree input {
  flex: 0 0 auto;
  margin: 2px 0 0;
}

.krona-chat__agree.has-error span {
  color: #c62828;
}

.krona-chat__primary {
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-radius: 11px;
  color: #fff;
  background: var(--kc-primary);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 7px 18px rgba(55, 100, 29, .17);
}

.krona-chat__primary:hover,
.krona-chat__primary:focus {
  filter: brightness(.96);
  outline: none;
}

.krona-chat__primary[disabled] {
  opacity: .6;
  cursor: wait;
}

.krona-chat__notice {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #ffc9c7;
  border-radius: 9px;
  color: #a82424;
  background: #fff1f0;
  font-size: 12px;
}

.krona-chat__dialog {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  background: var(--kc-bg);
}

.krona-chat__welcome {
  margin: 12px 14px 0;
  padding: 10px 12px;
  border: 1px solid #e7ecef;
  border-radius: 10px;
  color: #64737c;
  background: rgba(255,255,255,.86);
  font-size: 12px;
}

.krona-chat__messages {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 9px;
  padding: 14px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.krona-chat__message {
  display: flex;
  max-width: 84%;
  flex-direction: column;
  align-self: flex-start;
}

.krona-chat__message.is-own {
  align-self: flex-end;
}

.krona-chat__message-author {
  margin: 0 7px 3px;
  color: var(--kc-muted);
  font-size: 11px;
}

.krona-chat__message.is-own .krona-chat__message-author {
  display: none;
}

.krona-chat__bubble {
  padding: 9px 12px 7px;
  border: 1px solid var(--kc-border);
  border-radius: 15px 15px 15px 4px;
  color: var(--kc-text);
  background: #fff;
  box-shadow: 0 2px 7px rgba(25, 36, 43, .05);
}

.krona-chat__message.is-own .krona-chat__bubble {
  border-color: transparent;
  border-radius: 15px 15px 4px 15px;
  color: #fff;
  background: var(--kc-primary);
}

.krona-chat__message-text {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.krona-chat__message-time {
  display: block;
  margin-top: 4px;
  color: #97a2a8;
  font-size: 10px;
  text-align: right;
}

.krona-chat__message.is-own .krona-chat__message-time {
  color: rgba(255,255,255,.76);
}

.krona-chat__dialog-error {
  flex: 0 0 auto;
  margin: 0 12px 8px;
}

.krona-chat__composer {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--kc-border);
  background: #fff;
}

.krona-chat__composer textarea {
  display: block;
  width: 100%;
  min-height: 42px;
  max-height: 112px;
  padding: 10px 12px;
  resize: none;
  overflow-y: auto;
  border: 1px solid #d8dee2;
  border-radius: 13px;
  color: var(--kc-text);
  background: #fff;
  outline: none;
}

.krona-chat__composer textarea:focus {
  border-color: var(--kc-accent);
  box-shadow: 0 0 0 3px rgba(255, 175, 63, .14);
}

.krona-chat__composer button {
  display: flex;
  flex: 0 0 42px;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: var(--kc-accent);
  cursor: pointer;
}

.krona-chat__composer button svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.krona-chat__composer button[disabled] {
  opacity: .6;
  cursor: wait;
}

.krona-chat__account-line {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  min-height: 32px;
  padding: 0 13px 8px;
  color: var(--kc-muted);
  background: #fff;
  font-size: 11px;
}

.krona-chat__customer-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.krona-chat__logout {
  flex: 0 0 auto;
  padding: 3px 0 3px 10px;
  border: 0;
  color: #8a969d;
  background: transparent;
  cursor: pointer;
  text-decoration: underline;
}

@media (max-width: 520px) {
  .krona-chat {
    right: 12px;
    bottom: 64px;
  }

  .krona-chat__launcher {
    height: 56px;
    padding: 0 17px;
  }

  .krona-chat__panel {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: min(82vh, 650px);
    max-height: 92vh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 18px 18px 0 0;
    transform-origin: center bottom;
  }
}

@media (max-width: 360px) {
  .krona-chat__auth {
    padding: 15px;
  }

  .krona-chat__header {
    min-height: 70px;
    padding-left: 13px;
  }

  .krona-chat__avatar {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }
}
