.support-widget {
  inset: 0;
  pointer-events: none;
  position: fixed;
  z-index: 1500;
}

.support-widget * {
  box-sizing: border-box;
}

.support-widget button,
.support-widget input,
.support-widget textarea {
  font: inherit;
}

.support-widget button {
  cursor: pointer;
}

.support-widget-toggle {
  align-items: center;
  background: #000;
  border: 2px solid #000;
  box-shadow: 6px 6px 0 #ff006e;
  color: #fff;
  display: inline-flex;
  font-weight: 900;
  gap: 8px;
  height: 46px;
  justify-content: center;
  letter-spacing: 0;
  pointer-events: auto;
  position: fixed;
  right: clamp(16px, 2vw, 28px);
  bottom: calc(20px + env(safe-area-inset-bottom));
  min-width: 106px;
  padding: 0 15px;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.support-widget-toggle:hover {
  box-shadow: 4px 4px 0 #ff006e;
  transform: translate(2px, 2px);
}

.support-widget-toggle svg {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
  width: 18px;
}

.support-widget-panel[hidden],
.support-lead-form[hidden] {
  display: none;
}

.support-widget-panel {
  background: #fff;
  border: 3px solid #000;
  box-shadow: 9px 9px 0 #00d9ff;
  color: #0f172a;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  height: min(72vh, 660px);
  overflow: hidden;
  pointer-events: auto;
  position: fixed;
  right: clamp(16px, 2vw, 28px);
  bottom: calc(78px + env(safe-area-inset-bottom));
  width: min(92vw, 390px);
}

.support-widget-header {
  align-items: center;
  background: #ffe500;
  border-bottom: 3px solid #000;
  cursor: grab;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 11px 13px;
  touch-action: none;
  user-select: none;
}

.support-widget.is-dragging .support-widget-header {
  cursor: grabbing;
}

.support-resize-handle {
  display: block;
  pointer-events: auto;
  position: absolute;
  z-index: 4;
}

.support-resize-handle-top,
.support-resize-handle-bottom {
  cursor: ns-resize;
  height: 8px;
  left: 0;
  right: 0;
}

.support-resize-handle-top {
  top: 0;
}

.support-resize-handle-bottom {
  bottom: 0;
}

.support-resize-handle-left,
.support-resize-handle-right {
  bottom: 0;
  cursor: ew-resize;
  top: 0;
  width: 8px;
}

.support-resize-handle-left {
  left: 0;
}

.support-resize-handle-right {
  right: 0;
}

.support-widget-kicker {
  color: #475569;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1;
  margin: 0 0 4px;
  text-transform: uppercase;
}

.support-widget-header h2 {
  color: #000;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.1;
  margin: 0;
}

.support-widget-close {
  align-items: center;
  background: #fff;
  border: 2px solid #000;
  color: #000;
  display: inline-flex;
  font-size: 22px;
  font-weight: 900;
  height: 32px;
  justify-content: center;
  line-height: 1;
  padding: 0 0 2px;
  position: relative;
  width: 32px;
  z-index: 5;
}

.support-widget-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px;
}

.support-widget-messages::-webkit-scrollbar {
  width: 8px;
}

.support-widget-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

.support-message {
  border: 2px solid #000;
  max-width: 88%;
  padding: 10px 12px;
}

.support-message-agent {
  align-self: flex-start;
  background: #fff;
}

.support-message-user {
  align-self: flex-end;
  background: #000;
  color: #fff;
}

.support-message-content {
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.support-message-content p {
  margin: 0;
  white-space: normal;
}

.support-message-user .support-message-content p {
  white-space: pre-wrap;
}

.support-message-content p + p {
  margin-top: 8px;
}

.support-message-content h3,
.support-message-content h4,
.support-message-content h5 {
  color: inherit;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.35;
  margin: 0 0 6px;
}

.support-message-content h3:not(:first-child),
.support-message-content h4:not(:first-child),
.support-message-content h5:not(:first-child) {
  margin-top: 8px;
}

.support-message-content ul,
.support-message-content ol {
  margin: 6px 0 0;
  padding-left: 18px;
}

.support-message-content li + li {
  margin-top: 3px;
}

.support-message-content blockquote {
  border-left: 3px solid #ffe500;
  color: #475569;
  margin: 8px 0 0;
  padding: 2px 0 2px 9px;
}

.support-message-content pre {
  background: #0f172a;
  color: #f8fafc;
  margin: 8px 0 0;
  max-width: 100%;
  overflow-x: auto;
  padding: 8px 10px;
}

.support-message-content code {
  background: rgba(15, 23, 42, 0.09);
  border: 1px solid rgba(15, 23, 42, 0.12);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
  padding: 1px 4px;
}

.support-message-content pre code {
  background: transparent;
  border: 0;
  color: inherit;
  padding: 0;
}

.support-message-content a {
  color: #005bd3;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.support-message-user .support-message-content a {
  color: #fff;
}

.support-widget-quick {
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 14px 0;
  scrollbar-width: none;
}

.support-widget-quick:empty {
  display: none;
}

.support-widget-quick::-webkit-scrollbar {
  display: none;
}

.support-quick-btn {
  background: #fff;
  border: 2px solid #000;
  color: #0f172a;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  padding: 8px 10px;
  white-space: nowrap;
}

.support-quick-btn:hover {
  background: #ffe500;
}

.support-lead-form {
  background: #e6f8ff;
  border: 2px solid #000;
  display: grid;
  gap: 10px;
  margin: 12px 14px 0;
  padding: 12px;
}

.support-lead-head {
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.support-lead-head h3 {
  color: #000;
  font-size: 15px;
  font-weight: 900;
  margin: 0 0 4px;
}

.support-lead-head p {
  color: #475569;
  font-size: 12px;
  line-height: 1.45;
  margin: 0;
}

.support-lead-close {
  align-items: center;
  background: #fff;
  border: 2px solid #000;
  color: #000;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 18px;
  font-weight: 900;
  height: 28px;
  justify-content: center;
  line-height: 1;
  padding: 0 0 2px;
  width: 28px;
}

.support-lead-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.support-lead-form label,
.support-input-label {
  color: #475569;
  display: grid;
  font-size: 12px;
  font-weight: 800;
  gap: 5px;
}

.support-lead-form input,
.support-lead-form textarea,
.support-chat-input {
  background: #fff;
  border: 2px solid #000;
  color: #0f172a;
  min-width: 0;
  outline: none;
  padding: 9px 10px;
}

.support-lead-form input:focus,
.support-lead-form textarea:focus,
.support-chat-input:focus {
  border-color: #ff006e;
}

.support-lead-form textarea,
.support-chat-input {
  resize: vertical;
}

.support-lead-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.support-lead-submit,
.support-lead-cancel {
  border: 2px solid #000;
  font-size: 13px;
  font-weight: 900;
  padding: 8px 10px;
}

.support-lead-submit {
  background: #ff006e;
  color: #fff;
}

.support-lead-cancel {
  background: #fff;
  color: #0f172a;
}

.support-chat-form {
  display: grid;
  gap: 6px;
  padding: 12px 14px 14px;
}

.support-input-label {
  height: 1px;
  margin: -1px;
  overflow: hidden;
  position: absolute;
  width: 1px;
}

.support-input-row {
  align-items: end;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.support-chat-input {
  font-size: 14px;
  height: 44px;
  max-height: 116px;
  min-height: 44px;
}

.support-send-btn {
  align-items: center;
  background: #000;
  border: 2px solid #000;
  color: #fff;
  display: inline-flex;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.support-send-btn:hover {
  background: #ff006e;
}

.support-send-btn svg {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
  width: 18px;
}

.support-status {
  color: #64748b;
  font-size: 12px;
  margin: 0;
  min-height: 18px;
}

.support-widget.is-pending .support-send-btn,
.support-widget.is-pending .support-lead-submit {
  opacity: 0.7;
}

.support-widget-close:focus-visible,
.support-widget-toggle:focus-visible,
.support-quick-btn:focus-visible,
.support-send-btn:focus-visible,
.support-lead-close:focus-visible,
.support-lead-submit:focus-visible,
.support-lead-cancel:focus-visible {
  outline: 3px solid rgba(255, 0, 110, 0.35);
  outline-offset: 3px;
}

@media (max-width: 640px) {
  .support-widget-toggle {
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom));
  }

  .support-widget-panel {
    inset: auto 10px calc(72px + env(safe-area-inset-bottom));
    height: min(74vh, 620px);
    width: auto;
  }

  .support-lead-grid {
    grid-template-columns: 1fr;
  }
}
