/* Support chat widget — fixed left */

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.support-fab {
  position: fixed;
  left: 1rem;
  bottom: 1.25rem;
  z-index: 140;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 1rem 0.7rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease);
}

.support-fab:hover {
  background: #fff;
  transform: translateY(-1px);
}

.support-fab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.support-fab-icon {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
}

.support-fab-icon svg {
  width: 1.1rem;
  height: 1.1rem;
}

.support-fab-label {
  font-size: 0.92rem;
  font-weight: 600;
}

.support-fab-badge {
  position: absolute;
  top: -0.15rem;
  right: -0.15rem;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.15rem;
  text-align: center;
}

.support-panel {
  position: fixed;
  left: 1rem;
  bottom: 5.5rem;
  z-index: 141;
  width: min(25rem, calc(100vw - 2rem));
  height: min(36rem, calc(100dvh - 7rem));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 20px 70px rgba(43, 42, 38, 0.18), 0 2px 8px rgba(43, 42, 38, 0.05);
  overflow: hidden;
  animation: support-panel-in 0.2s ease;
}

@keyframes support-panel-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.support-panel [hidden], .support-panel[hidden] { display: none !important; }
.support-panel button, .support-panel textarea { font: inherit; }
.support-panel button { cursor: pointer; }
.support-panel button:focus-visible, .support-panel textarea:focus-visible,
.support-compose:has(#support-file:focus-visible) .support-image-label {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.support-panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid #eee8e2;
  flex-shrink: 0;
}
.support-avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 15px;
  background: var(--cream);
  color: #b34b2e;
}
.support-avatar svg, .support-welcome-icon svg { width: 24px; height: 24px; }
.support-heading { flex: 1; min-width: 0; }
.support-heading h2 { margin: 0; font-size: 17px; font-weight: 750; }
.support-heading p { margin: 3px 0 0; font-size: 12px; color: #726a63; }
.support-panel-close {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #f7f5f2;
  color: #726a63;
  font-size: 26px !important;
  line-height: 1;
}
.support-panel-close:hover { background: #eee8e2; color: var(--ink); }
.support-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #faf8f5;
}
.support-empty { margin: auto; padding: 12px 0; text-align: center; max-width: 310px; }
.support-welcome-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border: 1px solid #eeded2;
  border-radius: 20px;
  background: #fff1e6;
  color: #b34b2e;
}
.support-empty h3 { margin: 0 0 8px; font-size: 21px; letter-spacing: -0.5px; }
.support-empty p { margin: 0; font-size: 14px; line-height: 1.6; color: #726a63; }
.support-topics { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 22px; }
.support-topics button {
  padding: 10px 12px;
  min-height: 44px;
  border: 1px solid #e7ded5;
  border-radius: 12px;
  background: #fff;
  color: #63564c;
  font-size: 12px;
}
.support-topics button:hover { border-color: var(--accent); background: var(--cream); }
.support-bubble {
  flex-shrink: 0;
  max-width: 88%;
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.support-bubble-user { align-self: flex-end; background: #f9e4d7; color: #49392e; border-bottom-right-radius: 4px; }
.support-bubble-support { align-self: flex-start; background: #fff; color: var(--ink); border: 1px solid #ece5de; border-bottom-left-radius: 4px; }
.support-bubble-attach { display: block; padding: 10px 12px; border-radius: 10px; background: #00000008; color: inherit; text-decoration: none; font-weight: 600; }
.support-bubble-media { padding: 6px; width: min(260px, 88%); }
.support-bubble-media > div { padding: 4px 6px 8px; }
.support-image-link { display: block; overflow: hidden; border-radius: 11px; cursor: zoom-in; }
.support-bubble-image { display: block; width: 100%; max-height: 300px; object-fit: contain; background: #f2eee9; }
.support-form { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; max-height: 55%; overflow-y: auto; padding: 12px; border-top: 1px solid #eee8e2; background: #fff; }
.support-compose { display: flex; align-items: flex-end; gap: 4px; min-width: 0; padding: 5px; border: 1px solid #e7ded5; border-radius: 24px; background: #faf8f5; }
.support-compose:focus-within { border-color: #c88167; box-shadow: 0 0 0 2px #b94f300d; }
.support-form textarea { display: block; flex: 1; min-width: 0; width: 100%; min-height: 44px; max-height: 120px; resize: none; padding: 10px 4px; border: 0; border-radius: 0; background: transparent; color: var(--ink); font-size: 16px; line-height: 24px; box-shadow: none; }
.support-form textarea:focus-visible { outline: none; }
.support-form textarea::placeholder { color: #80776f; }
.support-image-label { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 44px; height: 44px; padding: 0; border: 0; color: #807167; background: transparent; border-radius: 50%; }
.support-image-label:hover { background: #eee8e2; }
.support-image-label svg, #support-send svg { width: 22px; height: 22px; }
.support-compose button[type="submit"] { display: grid; place-items: center; flex-shrink: 0; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: #b94f30; color: #fff; }
.support-compose button[type="submit"]:hover { background: #a74428; }
.support-compose-hint { font-size: 11px; text-align: center; color: #958980; }
.support-panel button:disabled { opacity: 0.55; cursor: not-allowed; }
.support-selected-file { position: relative; display: flex; align-items: center; gap: 12px; padding: 8px; border: 1px solid #ece5de; border-radius: 16px; background: #faf8f5; }
.support-file-name { flex: 1; min-width: 0; margin: 0; font-size: 12px; color: #655c54; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#support-file-preview { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; }
#support-file-remove { width: 44px; height: 44px; flex-shrink: 0; border: 0; border-radius: 50%; background: #eee8e2; color: #655c54; font-size: 22px; }
.support-image-viewer { position: fixed; width: min(900px, 94vw); max-width: 94vw; max-height: 94dvh; padding: 48px 12px 16px; border: 0; border-radius: 20px; background: #201e1c; color: #fff; text-align: center; box-shadow: 0 24px 80px #0006; }
.support-image-viewer::backdrop { background: #15120fd9; }
.support-image-viewer img { display: block; max-width: 100%; max-height: 76dvh; object-fit: contain; margin: 0 auto 12px; border-radius: 8px; }
.support-image-viewer button { position: absolute; top: 4px; right: 6px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: #fff; font-size: 30px; cursor: pointer; }
.support-image-viewer a { color: #fff; font: 13px system-ui, sans-serif; }
.support-image-viewer :focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.support-status { margin: 0; padding: 10px 16px; color: var(--err); background: #fff1ed; font-size: 13px; }
.support-status:empty { display: none; }
@media (prefers-reduced-motion: reduce) { .support-panel { animation: none; } }

@media (max-width: 959px) {
  .support-fab {
    gap: 0;
    padding: 0.55rem;
    bottom: calc(
      var(--bottom-nav-offset, var(--bottom-nav-h, 4.15rem)) + var(--vv-bottom-inset, 0px) + 0.85rem
    );
  }

  .support-fab-label {
    display: none;
  }

  body.support-open .bottom-nav {
    bottom: 0;
  }

  body.support-open .support-fab {
    bottom: calc(var(--bottom-nav-offset, var(--bottom-nav-h, 4.15rem)) + 0.85rem);
  }

  .support-panel {
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
    bottom: calc(
      var(--bottom-nav-offset, var(--bottom-nav-h, 4.15rem)) + var(--vv-bottom-inset, 0px) + 4.1rem
    );
    height: min(
      26rem,
      calc(100dvh - var(--bottom-nav-offset, var(--bottom-nav-h, 4.15rem)) - 6.5rem)
    );
  }

  body.support-open .support-panel {
    bottom: calc(var(--bottom-nav-offset, var(--bottom-nav-h, 4.15rem)) + 0.75rem);
    height: min(
      70dvh,
      calc(100dvh - var(--bottom-nav-offset, var(--bottom-nav-h, 4.15rem)) - 1.5rem)
    );
  }

  body.is-design-page .support-fab {
    bottom: calc(
      var(--bottom-nav-offset, var(--bottom-nav-h, 4.15rem)) + var(--vv-bottom-inset, 0px) + 0.55rem
    );
  }

  body.is-design-page.support-open .support-fab {
    bottom: calc(var(--bottom-nav-offset, var(--bottom-nav-h, 4.15rem)) + 0.55rem);
  }

  /* В полноэкранном превью конструктора нижний левый угол занят панелью
     инструментов (кнопка «Слои» и т.д.) — фиксированная там же кнопка
     поддержки перекрывала её. Уводим кнопку наверх, под шапку, где в этом
     режиме место свободно (панель черновиков прижата вправо). */
  body.is-design-page.design-pane-preview-active .support-fab {
    top: calc(var(--header-h, 3.7rem) + 0.5rem);
    bottom: auto;
  }

  body.is-design-page .support-panel {
    bottom: calc(
      var(--bottom-nav-offset, var(--bottom-nav-h, 4.15rem)) + var(--vv-bottom-inset, 0px) + 3.6rem
    );
    height: min(
      26rem,
      calc(100dvh - var(--bottom-nav-offset, var(--bottom-nav-h, 4.15rem)) - 5.5rem)
    );
  }
}
@media (max-width: 959px) {
  body.support-open .support-panel { height: min(75dvh, calc(100dvh - var(--bottom-nav-offset, var(--bottom-nav-h, 4.15rem)) - 1.5rem)); }
  body.is-home-page.support-open .support-panel { height: min(75dvh, calc(100dvh - var(--bottom-nav-offset, var(--bottom-nav-h, 4.15rem)) - 1.5rem)); }
  .support-panel-head { padding: 14px 16px; }
}
