/* Telegram-bridged support widget. Brand tokens (--gold, --bg-panel, …) are the
   same ones declared in site.css :root. No inline styles anywhere - the site
   ships a strict CSP (style-src 'self'). */

.zh-support {
  position: fixed;
  right: clamp(14px, 4vw, 26px);
  bottom: clamp(14px, 4vw, 26px);
  z-index: 80;
  font: 15px/1.55 "Bahnschrift", "Segoe UI", Tahoma, sans-serif;
}

/* No-JS / not-initialised: keep the widget out of the way entirely. */
.zh-support:not(.is-ready) {
  display: none;
}

/* During the home-page intro reel, fade with the gated content. */
html.home-intro-active .zh-support {
  opacity: 0;
  pointer-events: none;
}

/* ---- Launcher ----------------------------------------------------------- */
.zh-support-launcher {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 52px;
  padding: 0 20px 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(212, 165, 116, 0.44);
  color: var(--gold-bright, #f4cc98);
  background: linear-gradient(180deg, rgba(36, 28, 18, 0.96), rgba(20, 16, 11, 0.96));
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.42), inset 0 0 0 1px rgba(244, 204, 152, 0.06);
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.zh-support-launcher:hover {
  transform: translateY(-1px);
  border-color: rgba(212, 165, 116, 0.7);
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.5), 0 0 22px rgba(212, 165, 116, 0.18);
}

.zh-support-launcher:focus-visible {
  outline: 2px solid var(--gold-bright, #f4cc98);
  outline-offset: 3px;
}

.zh-support-launcher-icon {
  display: inline-flex;
}

.zh-support.is-open .zh-support-launcher {
  opacity: 0;
  transform: scale(0.85);
  pointer-events: none;
}

/* Unread-reply badge on the launcher. */
.zh-support-badge {
  position: absolute;
  top: -6px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #e0533d;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  box-shadow: 0 0 0 2px rgba(12, 9, 6, 0.9);
}

.zh-support-badge[hidden] {
  display: none;
}

/* ---- Panel -------------------------------------------------------------- */
.zh-support-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(370px, calc(100vw - 28px));
  height: min(560px, calc(100vh - 110px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  background: var(--bg-panel, rgba(16, 22, 31, 0.95));
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  transform-origin: bottom right;
  /* Closed state - animated open via .is-open. */
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.97);
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease, visibility 200ms ease;
}

.zh-support.is-open .zh-support-panel {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
}

.zh-support-header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 14px 13px 16px;
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  background: linear-gradient(180deg, rgba(212, 165, 116, 0.1), rgba(212, 165, 116, 0));
}

.zh-support-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--gold-bright, #f4cc98);
  border: 1px solid rgba(212, 165, 116, 0.4);
  background: rgba(212, 165, 116, 0.1);
  flex: none;
}

.zh-support-heading {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  flex: 1 1 auto;
  min-width: 0;
}

.zh-support-title {
  color: var(--text-strong, #f1f5fa);
  font-size: 0.98rem;
}

.zh-support-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted, #8691a0);
  font-size: 0.78rem;
}

.zh-support-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4cd07d;
  box-shadow: 0 0 8px rgba(76, 208, 125, 0.7);
}

.zh-support-close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid transparent;
  color: var(--text-muted, #8691a0);
  background: transparent;
  cursor: pointer;
  transition: 160ms ease;
}

.zh-support-close:hover {
  color: var(--text-strong, #f1f5fa);
  border-color: var(--border, rgba(255, 255, 255, 0.12));
  background: rgba(255, 255, 255, 0.05);
}

/* ---- Message log -------------------------------------------------------- */
.zh-support-log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.zh-support-log::-webkit-scrollbar {
  width: 8px;
}

.zh-support-log::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
}

.zh-support-msg {
  display: flex;
  flex-direction: column;
  max-width: 84%;
}

.zh-support-author {
  margin: 0 4px 3px;
  color: var(--gold, #d4a574);
  font-size: 0.74rem;
  font-weight: 700;
}

.zh-support-bubble {
  padding: 9px 13px;
  border-radius: 15px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Visitor (own) - right aligned, gold-tinted. */
.zh-support-msg-visitor {
  align-self: flex-end;
  align-items: flex-end;
}

.zh-support-msg-visitor .zh-support-bubble {
  color: #1a130a;
  background: linear-gradient(180deg, var(--gold-bright, #f4cc98), var(--gold, #d4a574));
  border-bottom-right-radius: 5px;
  font-weight: 600;
}

/* Operator + system - left aligned, dark glass. */
.zh-support-msg-operator,
.zh-support-msg-system {
  align-self: flex-start;
  align-items: flex-start;
}

.zh-support-msg-operator .zh-support-bubble {
  color: var(--text, #ccd3dd);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  border-bottom-left-radius: 5px;
}

.zh-support-msg-system .zh-support-bubble {
  color: var(--text-muted, #8691a0);
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--border, rgba(255, 255, 255, 0.1));
  font-size: 0.9rem;
}

/* ---- Error + hint ------------------------------------------------------- */
.zh-support-error {
  margin: 0;
  padding: 8px 16px;
  color: #f3b0a3;
  background: rgba(224, 83, 61, 0.12);
  border-top: 1px solid rgba(224, 83, 61, 0.25);
  font-size: 0.82rem;
}

.zh-support-error[hidden] {
  display: none;
}

/* ---- Composer ----------------------------------------------------------- */
.zh-support-form {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  padding: 11px 12px;
  border-top: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  background: rgba(8, 12, 18, 0.6);
}

.zh-support-input {
  flex: 1 1 auto;
  resize: none;
  max-height: 120px;
  padding: 10px 13px;
  border-radius: 14px;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-strong, #f1f5fa);
  font: inherit;
}

.zh-support-input::placeholder {
  color: var(--text-muted, #8691a0);
}

.zh-support-input:focus {
  outline: none;
  border-color: rgba(212, 165, 116, 0.5);
  background: rgba(255, 255, 255, 0.06);
}

.zh-support-submit {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(212, 165, 116, 0.44);
  color: #1a130a;
  background: linear-gradient(180deg, var(--gold-bright, #f4cc98), var(--gold, #d4a574));
  cursor: pointer;
  transition: 160ms ease;
}

.zh-support-submit:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.zh-support-submit:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
  filter: none;
}

.zh-support-hint {
  margin: 0;
  padding: 0 16px 12px;
  color: var(--text-muted, #8691a0);
  font-size: 0.74rem;
  background: rgba(8, 12, 18, 0.6);
}

/* ---- Mobile sheet ------------------------------------------------------- */
@media (max-width: 480px) {
  .zh-support {
    right: 14px;
    bottom: 14px;
  }

  .zh-support-panel {
    width: calc(100vw - 24px);
    height: min(72vh, calc(100vh - 96px));
  }

  .zh-support-launcher-label {
    display: none;
  }

  .zh-support-launcher {
    padding: 0;
    width: 56px;
    height: 56px;
    min-height: 0;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .zh-support-launcher,
  .zh-support-panel,
  .zh-support-submit {
    transition: none;
  }
}
