:root {
  --chat-surface: #17212b;
  --chat-surface-strong: rgba(255, 255, 255, 0.08);
  --chat-border: rgba(255, 255, 255, 0.09);
  --chat-text: #ecf3fb;
  --chat-muted: #8ea8c1;
  --chat-accent: #2aabee;
  --chat-accent-2: #2097d7;
  --chat-danger: #ff6b7a;
  --chat-ok: #5dc473;
  --chat-bubble-out: #2b5278;
  --chat-bubble-in: #182533;
  --chat-shadow: 0 20px 60px rgba(0, 0, 0, 0.36);
}

.support-chat-root,
.support-chat-root * {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.support-chat-root [hidden] { display: none !important; }
body.support-chat-open { overflow: hidden; }

.support-chat-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1200;
  border: 0;
  width: 62px;
  height: 62px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: linear-gradient(180deg, var(--chat-accent), var(--chat-accent-2));
  color: #fff;
  box-shadow: var(--chat-shadow);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}

.support-chat-root.is-open .support-chat-launcher { display: none !important; }
.support-chat-launcher:hover { transform: translateY(-2px); }
.support-chat-launcher svg { width: 29px; height: 29px; }

.support-chat-unread {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--chat-danger);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid #0e1621;
}

.support-chat-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 12, 22, 0.52);
  z-index: 1198;
  backdrop-filter: blur(4px);
}

.support-chat-window {
  position: fixed;
  right: 22px;
  bottom: 96px;
  width: min(430px, calc(100vw - 24px));
  height: min(736px, calc(100vh - 116px));
  z-index: 1199;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  border-radius: 26px;
  border: 1px solid var(--chat-border);
  background:
    radial-gradient(circle at top left, rgba(42, 171, 238, 0.12), transparent 26%),
    linear-gradient(180deg, rgba(16, 25, 35, 0.98), rgba(16, 25, 35, 0.96));
  box-shadow: var(--chat-shadow);
  overflow: hidden;
  backdrop-filter: blur(18px);
}

.support-chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--chat-border);
  background: rgba(16, 25, 35, 0.96);
}

.support-chat-header-main,
.support-chat-header-actions,
.support-chat-composer-row,
.support-chat-floating-inline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.support-chat-header-main {
  min-width: 0;
}

.support-chat-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 19px;
  color: #fff;
  background: linear-gradient(180deg, #2aabee, #3f84e5);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.support-chat-titlewrap { min-width: 0; }
.support-chat-kicker {
  color: rgba(236, 243, 251, 0.62);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.support-chat-title {
  margin: 4px 0 0;
  font-size: 18px;
  line-height: 1.15;
  font-weight: 700;
}
.support-chat-subtitle {
  color: var(--chat-muted);
  font-size: 13px;
  margin-top: 3px;
  line-height: 1.35;
}

.support-chat-icon-btn,
.support-chat-send,
.support-chat-file-btn,
.support-chat-copy {
  border: 1px solid transparent;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--chat-text);
}

.support-chat-icon-btn,
.support-chat-file-btn {
  width: 42px;
  height: 42px;
  min-width: 42px;
  display: inline-grid;
  place-items: center;
  padding: 0;
}

.support-chat-send {
  min-width: max-content;
  padding: 0 17px;
  min-height: 42px;
  white-space: nowrap;
  font-weight: 700;
  background: linear-gradient(180deg, var(--chat-accent), var(--chat-accent-2));
  box-shadow: 0 12px 24px rgba(42, 171, 238, 0.22);
}

.support-chat-status-row {
  display: grid;
  gap: 8px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--chat-border);
}

.support-chat-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: 100%;
  min-height: 30px;
  border-radius: 999px;
  border: 1px solid rgba(93, 196, 115, 0.22);
  background: rgba(93, 196, 115, 0.1);
  color: #cbf7d4;
  font-size: 12px;
  padding: 0 12px;
}

.support-chat-status {
  color: var(--chat-muted);
  font-size: 13px;
  line-height: 1.45;
}

.support-chat-status.is-blocked {
  color: #ffd0d8;
}

.support-chat-messages {
  overflow: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  overscroll-behavior: contain;
}

.support-chat-empty {
  margin: auto;
  text-align: center;
  border: 1px dashed var(--chat-border);
  border-radius: 22px;
  padding: 24px 20px;
  width: 100%;
  display: grid;
  gap: 8px;
}

.support-chat-empty-icon { font-size: 34px; }
.support-chat-empty-title { font-size: 18px; font-weight: 700; }
.support-chat-empty-text,
.support-chat-filemeta,
.support-chat-meta { color: var(--chat-muted); font-size: 13px; }

.support-chat-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(92%, 420px);
  align-self: flex-start;
}
.support-chat-row.mine { align-self: flex-end; }
.support-chat-row.theirs { align-self: flex-start; }
.support-chat-row.has-attachments { width: min(94%, 430px); }

.support-chat-bubble {
  position: relative;
  padding: 13px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: var(--chat-bubble-in);
  word-break: break-word;
  width: 100%;
}

.support-chat-row.mine .support-chat-bubble {
  background: linear-gradient(180deg, rgba(43, 82, 120, 0.98), rgba(39, 74, 108, 0.98));
}

.support-chat-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  opacity: 0;
  transition: opacity .16s ease;
}

.support-chat-bubble:hover .support-chat-copy,
.support-chat-bubble:focus-within .support-chat-copy { opacity: 1; }
.support-chat-body a { color: #8fd6ff; }
.support-chat-body p { margin: 0; text-align: left; font-size: 15px; line-height: 1.48; }
.support-chat-row.emoji-only { width: auto; max-width: none; }
.support-chat-row.emoji-only .support-chat-bubble { min-width: 0; width: auto; padding-right: 16px; }
.support-chat-row.emoji-only .support-chat-body p { font-size: 30px; line-height: 1.1; }

.support-chat-attachments {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  width: 100%;
}

.support-chat-attachments + .support-chat-body {
  margin-top: 10px;
}

.support-chat-attachments.is-single-image {
  grid-template-columns: 1fr;
  width: 100%;
}

.support-chat-image,
.support-chat-file {
  border: 1px solid var(--chat-border);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  text-decoration: none;
  display: block;
}

.support-chat-image img {
  width: 100%;
  display: block;
  max-height: 360px;
  object-fit: cover;
}

.support-chat-attachments.is-single-image .support-chat-image img {
  max-height: 380px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.03);
}

.support-chat-file {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  align-items: center;
}

.support-chat-fileicon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  font-size: 24px;
  background: rgba(255, 255, 255, 0.03);
}

.support-chat-filecontent {
  padding: 10px 12px;
  display: grid;
  gap: 4px;
  min-width: 0;
}

.support-chat-filename {
  font-weight: 600;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.support-chat-composer {
  border-top: 1px solid var(--chat-border);
  padding: 12px 16px 16px;
  display: grid;
  gap: 10px;
  background: rgba(16, 25, 35, 0.96);
}

.support-chat-composer-row {
  align-items: flex-end;
  gap: 8px;
  border-radius: 20px;
  border: 1px solid var(--chat-border);
  background: rgba(255, 255, 255, 0.05);
  padding: 8px;
}

.support-chat-textarea {
  width: 100%;
  min-height: 46px;
  max-height: 160px;
  resize: none;
  border: 0;
  background: transparent;
  color: var(--chat-text);
  padding: 11px 8px;
  outline: none;
  font: inherit;
  font-size: 15px;
  line-height: 1.45;
}

.support-chat-textarea::placeholder { color: rgba(142, 168, 193, 0.75); }

.support-chat-emoji {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid var(--chat-border);
  background: rgba(255, 255, 255, 0.05);
}

.support-chat-emoji button {
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--chat-text);
  padding: 8px 0;
}

.support-chat-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.support-chat-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--chat-border);
  padding: 0 11px;
  color: var(--chat-text);
  font-size: 13px;
}

.support-chat-chip button {
  border: 0;
  background: transparent;
  color: #ffd0d8;
  padding: 0;
}

.support-chat-floating-inline {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

@media (max-width: 720px) {
  .support-chat-launcher { right: 14px; bottom: 14px; width: 58px; height: 58px; }

  .support-chat-window {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 100dvh;
    border-radius: 24px 24px 0 0;
  }

  .support-chat-header { padding: 16px 14px 12px; }
  .support-chat-status-row { padding: 11px 14px; }
  .support-chat-composer { padding: 12px 12px max(12px, env(safe-area-inset-bottom)); }
  .support-chat-emoji { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .support-chat-row,
  .support-chat-row.has-attachments { width: 100%; }
  .support-chat-attachments,
  .support-chat-attachments.is-single-image { width: 100%; }
  .support-chat-send { padding-inline: 14px; font-size: 14px; }
}

/* --- 2026-04 refinement patch --- */
html, body, .support-chat-root, .support-chat-window, .support-chat-messages {
  overflow-x: hidden;
}
.support-chat-root,
.support-chat-root * { overscroll-behavior-x: none; }
.support-chat-window {
  overflow: hidden;
}
.support-chat-messages {
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  background-color: #0f1822;
  background-image:
    radial-gradient(circle at 18% 18%, rgba(93,196,115,0.07), transparent 22%),
    radial-gradient(circle at 85% 10%, rgba(42,171,238,0.09), transparent 18%),
    radial-gradient(circle at 12% 88%, rgba(255,255,255,0.05), transparent 24%),
    linear-gradient(135deg, rgba(255,255,255,0.022) 25%, transparent 25%),
    linear-gradient(225deg, rgba(255,255,255,0.016) 25%, transparent 25%),
    linear-gradient(315deg, rgba(255,255,255,0.016) 25%, transparent 25%),
    linear-gradient(45deg, rgba(255,255,255,0.022) 25%, transparent 25%);
  background-size: auto, auto, auto, 24px 24px, 24px 24px, 24px 24px, 24px 24px;
  background-position: 0 0, 0 0, 0 0, 0 0, 12px 0, 12px -12px, 0 12px;
}
.support-chat-composer-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: end;
  gap: 8px;
  overflow: hidden;
}
.support-chat-textarea {
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
}
.support-chat-send {
  min-width: 116px;
  font-size: 14px;
  padding: 0 16px;
}
.support-chat-copy { display: none !important; }
.support-chat-meta {
  gap: 8px;
}
.support-chat-row { gap: 6px; }
.support-chat-bubble {
  box-shadow: 0 12px 28px rgba(0,0,0,0.22);
  max-width: 100%;
}
.support-chat-body p { overflow-wrap: anywhere; }
.support-chat-read-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  width: max-content;
}
.support-chat-row.mine .support-chat-read-status { align-self: flex-end; }
.support-chat-read-status.is-read {
  background: rgba(93, 196, 115, 0.12);
  color: #bceec7;
}
.support-chat-read-status.is-unread {
  background: rgba(255,255,255,0.06);
  color: #b7cde1;
}
.support-chat-attachments,
.support-chat-file,
.support-chat-image { max-width: 100%; }
.support-chat-action-menu {
  position: fixed;
  inset: 0;
  z-index: 1210;
}
.support-chat-action-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7,12,19,0.44);
  backdrop-filter: blur(5px);
}
.support-chat-action-panel {
  position: absolute;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(320px, calc(100vw - 24px));
  padding: 10px;
  border-radius: 22px;
  border: 1px solid var(--chat-border);
  background: linear-gradient(180deg, rgba(24,36,48,0.98), rgba(15,24,34,0.98));
  box-shadow: 0 18px 44px rgba(0,0,0,0.34);
}
.support-chat-action-list {
  display: grid;
  gap: 8px;
}
.support-chat-action-btn {
  min-height: 48px;
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 16px;
  background: rgba(255,255,255,0.05);
  color: var(--chat-text);
  text-align: left;
  padding: 0 14px;
}
@media (max-width: 720px) {
  .support-chat-composer-row {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: 6px;
  }
  .support-chat-send {
    min-width: 102px;
    padding-inline: 14px;
    font-size: 13px;
  }
}


/* --- 2026-04 alignment and stability fixes --- */
.support-chat-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-inline: 4px;
}
.support-chat-row.mine .support-chat-meta {
  justify-content: flex-end;
  text-align: right;
}
.support-chat-row.theirs .support-chat-meta {
  justify-content: flex-start;
}
.support-chat-row {
  width: auto;
  max-width: min(92%, 420px);
}
.support-chat-row.has-attachments {
  width: min(94%, 430px);
  max-width: min(94%, 430px);
}
.support-chat-bubble {
  border-color: rgba(66, 100, 136, 0.52);
}
.support-chat-row.mine .support-chat-bubble {
  border-color: rgba(88, 181, 247, 0.56);
  box-shadow: 0 12px 28px rgba(0,0,0,0.22), 0 0 0 1px rgba(88, 181, 247, 0.08) inset;
}
.support-chat-row.theirs .support-chat-bubble {
  border-color: rgba(66, 100, 136, 0.52);
}
.support-chat-body p,
.support-chat-filename,
.support-chat-filemeta,
.support-chat-meta {
  overflow-wrap: anywhere;
  word-break: break-word;
}
@media (max-width: 720px) {
  .support-chat-row {
    width: auto;
    max-width: 88%;
  }
  .support-chat-row.has-attachments {
    width: 94%;
    max-width: 94%;
  }
}


/* --- 2026-04 final instant/block/text polish --- */
.support-chat-body p {
  font-size: 14px !important;
  line-height: 1.42 !important;
}


/* --- 2026-04 long press native selection fix --- */
.support-chat-bubble,
.support-chat-bubble * {
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.support-chat-bubble {
  touch-action: manipulation;
}
