.live-chat-root {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 9000;
  font-family: var(--font, 'Instrument Sans', system-ui, sans-serif);
}

.live-chat-toggle {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.85rem 1.1rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-light, #14b8a6), var(--accent, #0d9488));
  color: #fff;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(13, 148, 136, 0.28);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.live-chat-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(13, 148, 136, 0.34);
}

.live-chat-toggle svg {
  flex-shrink: 0;
}

.live-chat-toggle-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #86efac;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.live-chat-toggle-dot.is-offline {
  background: #fbbf24;
}

.live-chat-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.85rem);
  width: min(360px, calc(100vw - 2rem));
  height: auto;
  max-height: min(480px, calc(100vh - 6rem));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #dbe4ee);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(21, 37, 53, 0.16);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.live-chat-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.live-chat-panel:has([data-live-chat-compose]) {
  height: min(480px, calc(100vh - 6rem));
}

.live-chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.8rem 0.9rem 0.7rem;
  background: linear-gradient(180deg, rgba(13, 148, 136, 0.08), transparent);
  border-bottom: 1px solid var(--border, #dbe4ee);
}

.live-chat-header h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--text, #152535);
}

.live-chat-header p {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted, #5a6b7d);
}

.live-chat-close {
  border: none;
  background: transparent;
  color: var(--text-muted, #5a6b7d);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.15rem 0.25rem;
}

.live-chat-body {
  min-height: 0;
  overflow-y: auto;
  padding: 0.75rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.live-chat-body--start {
  justify-content: flex-start;
}

.live-chat-messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 0;
}

.live-chat-message {
  max-width: 88%;
  padding: 0.65rem 0.8rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  word-break: break-word;
}

.live-chat-message--visitor {
  align-self: flex-end;
  background: var(--accent, #0d9488);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.live-chat-message--admin {
  align-self: flex-start;
  background: var(--bg-alt, #eef3f8);
  color: var(--text, #152535);
  border-bottom-left-radius: 4px;
}

.live-chat-message-meta {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.72rem;
  opacity: 0.75;
}

.live-chat-intro {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted, #5a6b7d);
}

.live-chat-form .captcha-widget {
  margin: 0.15rem 0 0.35rem;
  min-height: 65px;
}

.live-chat-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.live-chat-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.live-chat-form label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text, #152535);
}

.live-chat-form input,
.live-chat-form textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border, #dbe4ee);
  border-radius: 10px;
  font: inherit;
  font-size: 0.9rem;
  background: #fff;
  color: var(--text, #152535);
}

.live-chat-form input:focus,
.live-chat-form textarea:focus {
  outline: none;
  border-color: var(--accent, #0d9488);
  box-shadow: 0 0 0 3px var(--accent-glow, rgba(13, 148, 136, 0.14));
}

.live-chat-form textarea {
  resize: vertical;
  min-height: 72px;
}

.live-chat-actions {
  display: flex;
  gap: 0.5rem;
}

.live-chat-submit {
  flex: 1;
  border: none;
  border-radius: 10px;
  padding: 0.7rem 1rem;
  background: var(--accent, #0d9488);
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.live-chat-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.live-chat-status {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted, #5a6b7d);
}

.live-chat-status.is-error {
  color: var(--danger, #ef4444);
}

.live-chat-status.is-success {
  color: var(--success, #10b981);
}

.live-chat-closed-hint {
  margin: 0;
  padding: 0.55rem 0.75rem;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--text-muted, #5a6b7d);
  background: var(--surface-muted, #f1f5f9);
  border-bottom: 1px solid var(--border, #dbe4ee);
}

.live-chat-compose {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  padding: 0.7rem 0.9rem 0.85rem;
  border-top: 1px solid var(--border, #dbe4ee);
  background: var(--surface, #fff);
}

.live-chat-compose textarea {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  max-height: 100px;
  resize: none;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border, #dbe4ee);
  border-radius: 10px;
  font: inherit;
  font-size: 0.9rem;
  box-sizing: border-box;
}

.live-chat-compose textarea:focus {
  outline: none;
  border-color: var(--accent, #0d9488);
  box-shadow: 0 0 0 3px var(--accent-glow, rgba(13, 148, 136, 0.14));
}

.live-chat-compose button {
  flex-shrink: 0;
  border: none;
  border-radius: 10px;
  padding: 0.55rem 0.9rem;
  background: var(--accent, #0d9488);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

@media (max-width: 480px) {
  .live-chat-root {
    right: 0.75rem;
    bottom: 0.75rem;
  }

  .live-chat-panel {
    width: calc(100vw - 1.5rem);
  }
}