.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.livechat-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2000;
}

.livechat-toggle {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(65, 55, 136, 0.45);
}

.livechat-panel {
  position: absolute;
  right: 0;
  bottom: 56px;
  width: min(360px, calc(100vw - 24px));
  border: 1px solid var(--divider);
  border-radius: 16px;
  background: #171526;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  display: none;
}

.livechat-root.open .livechat-panel {
  display: block;
}

.livechat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  border-bottom: 1px solid var(--divider);
}

.livechat-header h4 {
  font-size: 0.95rem;
}

.livechat-close {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.livechat-thread {
  min-height: 180px;
  max-height: 320px;
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.livechat-message {
  max-width: 86%;
  border-radius: 12px;
  padding: 10px;
  font-size: 0.9rem;
}

.livechat-message p {
  margin: 0 0 6px;
  line-height: 1.35;
  word-break: break-word;
}

.livechat-message time {
  display: block;
  color: #ffffff9a;
  font-size: 0.72rem;
}

.livechat-message.user {
  margin-left: auto;
  background: #5d4ef2;
}

.livechat-message.agent {
  margin-right: auto;
  background: #232036;
  border: 1px solid #39335a;
}

.livechat-message.system {
  margin-right: auto;
  background: #272236;
  border: 1px dashed #544a79;
}

.livechat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--divider);
}

.livechat-form textarea {
  resize: none;
  border-radius: 8px;
  border: 1px solid #3b365c;
  background: #110f1d;
  color: var(--text);
  padding: 8px;
  font-family: inherit;
}

.livechat-form button {
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
  color: #fff;
  background: #5649df;
  cursor: pointer;
}

@media (max-width: 600px) {
  .livechat-root {
    right: 12px;
    bottom: 12px;
  }

  .livechat-panel {
    width: min(360px, calc(100vw - 16px));
  }
}
