/* Customer support chat: launcher and panel. Colours come from the brand
   tokens in /api/brand.css and theme.css so every tenant and theme matches. */
.support-launcher {
  position: fixed;
  z-index: 17;
  right: 24px;
  bottom: 24px;
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  gap: 8px;
  padding: 0 20px 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: var(--shadow-sm, 0 8px 24px rgba(23, 20, 15, 0.24));
  color: var(--on-accent);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.support-launcher[hidden] {
  display: none;
}
.support-launcher:focus-visible,
.support-close:focus-visible,
.support-primary:focus-visible,
.support-secondary:focus-visible,
.support-input:focus-visible,
.support-link:focus-visible {
  outline: 2px solid var(--focus-ring, var(--accent));
  outline-offset: 2px;
}

/* The launcher gives way to anything that takes over the screen. */
body.support-chat-open .support-launcher,
body.market-filter-open .support-launcher,
body.trade-entry-open .support-launcher,
body.signin-page-open .support-launcher,
body.account-page-open .support-launcher,
body:not(.market-detail-route):has(.trade-drawer.open) .support-launcher {
  display: none;
}
body:has(.support-launcher:not([hidden])) .toast-region {
  bottom: 88px;
}

.support-backdrop {
  position: fixed;
  z-index: 64;
  inset: 0;
  background: var(--scrim, rgba(19, 20, 18, 0.42));
}
.support-backdrop[hidden] {
  display: none;
}
.support-panel {
  position: fixed;
  z-index: 65;
  top: 20px;
  right: 20px;
  bottom: 20px;
  display: flex;
  width: min(416px, calc(100vw - 24px));
  flex-direction: column;
  overflow: hidden;
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow-lg, 0 24px 64px rgba(19, 20, 18, 0.28));
  color: var(--ink);
}
.support-panel[hidden] {
  display: none;
}
.support-head {
  display: grid;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--line);
}
.support-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.support-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}
.support-close {
  display: grid;
  width: 44px;
  height: 44px;
  margin: -8px -8px -8px 0;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.support-chip {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 8px;
  justify-self: start;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--soft);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}
.support-chip-online {
  background: var(--yes-soft);
  color: var(--yes);
}
.support-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: currentcolor;
}
.support-info {
  display: grid;
  gap: 2px;
}
.support-info:empty {
  display: none;
}
.support-line {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.support-body {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  overflow-y: auto;
  background: var(--paper);
}
.support-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.support-bubble {
  max-width: 85%;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.support-bubble-team {
  align-self: flex-start;
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  background: var(--card);
}
.support-bubble-mine {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  background: var(--accent);
  color: var(--on-accent);
}
.support-time,
.support-context {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.support-time-mine {
  align-self: flex-end;
  margin-top: -6px;
}
.support-copy {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}
.support-notice {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--soft);
  font-size: 13px;
  line-height: 1.5;
}
.support-notice[hidden],
.support-sent[hidden] {
  display: none;
}
.support-notice-error {
  background: var(--no-soft);
  color: var(--no);
}
.support-sent {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}
.support-sent span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.support-actions {
  display: grid;
  gap: 10px;
}
.support-actions:empty {
  display: none;
}
.support-form {
  display: grid;
  gap: 10px;
  padding: 16px 20px 20px;
  border-top: 1px solid var(--line);
}
.support-form[hidden] {
  display: none;
}
.support-label {
  font-size: 13px;
  font-weight: 700;
}
.support-input {
  box-sizing: border-box;
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line-strong, var(--line));
  border-radius: 12px;
  background: var(--input-bg, var(--card));
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
}
.support-input:disabled {
  background: var(--soft);
  color: var(--muted);
}
.support-input-error {
  border-color: var(--no);
}
.support-form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.support-count {
  color: var(--muted);
  font-size: 12px;
}
.support-primary,
.support-secondary {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  border-radius: 999px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.support-primary {
  border: 0;
  background: var(--accent);
  color: var(--on-accent);
}
.support-primary:disabled {
  background: var(--soft);
  color: var(--muted);
  cursor: default;
}
.support-secondary {
  border: 1.5px solid var(--accent);
  background: var(--card);
  color: var(--accent);
}
.support-footer {
  margin: 0;
  padding: 14px 20px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.support-form:not([hidden]) + .support-footer {
  padding-top: 0;
  border-top: 0;
}
.support-link {
  color: var(--accent);
}

@media (max-width: 700px) {
  .support-launcher {
    right: 16px;
    bottom: calc(100px + env(safe-area-inset-bottom));
  }
  /* The market page pins its Yes and No buttons at the same offset. */
  body.market-detail-route .support-launcher {
    bottom: calc(208px + env(safe-area-inset-bottom));
  }
  body:has(.support-launcher:not([hidden])) .toast-region {
    bottom: calc(160px + env(safe-area-inset-bottom));
  }
  .support-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: calc(100dvh - 40px);
    height: 700px;
    border-radius: 24px 24px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    animation: support-sheet 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  }
  .support-panel::before {
    display: block;
    width: 40px;
    height: 4px;
    flex: none;
    margin: 10px auto 0;
    border-radius: 2px;
    background: var(--line-strong, var(--line));
    content: "";
  }
}
@keyframes support-sheet {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .support-panel {
    animation: none;
  }
}
