.domig-support-widget {
  --widget-border: rgba(20, 63, 57, 0.12);
  --widget-shadow: 0 28px 60px rgba(13, 35, 32, 0.18);
  --widget-primary: #0f6a5e;
  --widget-primary-soft: #e5f2ef;
  --widget-surface: #ffffff;
  --widget-muted: #6a7875;
  --widget-icon: #62716d;
  --widget-line: rgba(18, 46, 43, 0.08);
  --widget-chat-bg: linear-gradient(180deg, #f8fbfa 0%, #edf4f2 100%);
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10050;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
  font-family: "Segoe UI", Arial, sans-serif;
}

html.domig-widget-mobile-open,
body.domig-widget-mobile-open {
  /* Удалено: overflow: hidden !important; - позволяем скролл страницы даже когда widget открыт */
  overscroll-behavior: none;
}

.domig-support-widget--public {
  --widget-border: rgba(37, 99, 235, 0.14);
  --widget-shadow: 0 28px 60px rgba(37, 99, 235, 0.18);
  --widget-primary: #2563eb;
  --widget-primary-soft: #dbeafe;
  --widget-muted: #64748b;
  --widget-icon: #4b5563;
  --widget-line: rgba(37, 99, 235, 0.08);
  --widget-chat-bg: linear-gradient(180deg, #f8fbff 0%, #eef4ff 100%);
}

.domig-support-widget__toggle {
  width: 62px;
  height: 62px;
  border: none;
  border-radius: 18px;
  background: linear-gradient(135deg, #0d6458 0%, #1a8973 100%);
  color: #fff;
  box-shadow: 0 20px 44px rgba(11, 77, 67, 0.26);
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  z-index: 2;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.domig-support-widget__toggle-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  background: var(--widget-primary);
  color: #fff;
  box-shadow: 0 10px 18px rgba(14, 34, 31, 0.12);
  pointer-events: none;
}

.domig-support-widget__toggle-badge.is-hidden {
  display: none;
}

.domig-support-widget__toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 24px 52px rgba(11, 77, 67, 0.32);
}

.domig-support-widget--public .domig-support-widget__toggle {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  box-shadow: 0 20px 44px rgba(37, 99, 235, 0.28);
}

.domig-support-widget--public .domig-support-widget__toggle:hover {
  box-shadow: 0 24px 52px rgba(37, 99, 235, 0.34);
}

.domig-support-widget__toggle-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.domig-support-widget__toggle-glyph {
  display: none;
  font-size: 30px;
  line-height: 1;
}

.domig-support-widget__toggle-icon svg {
  width: 100%;
  height: 100%;
}

.domig-support-widget.is-open .domig-support-widget__toggle-icon {
  font-size: 28px;
  transform: rotate(90deg);
}

.domig-support-widget.is-open .domig-support-widget__toggle-icon svg {
  display: none;
}

.domig-support-widget.is-open .domig-support-widget__toggle-glyph {
  display: inline-block;
}

.domig-support-widget__panel {
  position: absolute;
  right: 0;
  bottom: 80px;
  width: 438px;
  height: 704px;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--widget-border);
  background: var(--widget-chat-bg);
  box-shadow: var(--widget-shadow);
  z-index: 3;
  pointer-events: auto;
  transform-origin: right bottom;
  visibility: visible;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s linear;
}

.domig-support-widget__panel--hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(18px) scale(0.94);
  transition-delay: 0s, 0s, 0.22s;
}

.domig-support-widget__panel--visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition-delay: 0s;
}

.domig-support-widget__shell,
.domig-support-widget__thread {
  height: 100%;
}

.domig-support-widget__header {
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--widget-line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
}

.domig-support-widget__headline {
  font-size: 24px;
  font-weight: 700;
  color: #183632;
}

.domig-support-widget__conversation-list {
  height: calc(100% - 69px);
  overflow-y: auto;
  padding: 8px 0;
}

.domig-support-widget__conversation-row {
  width: 100%;
  border: none;
  background: transparent;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 6px 12px;
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid rgba(18, 46, 43, 0.04);
}

.domig-support-widget__conversation-avatar {
  grid-column: 1;
  grid-row: 1 / span 2;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 106, 94, 0.09);
  color: #1e4f48;
  font-size: 15px;
  font-weight: 700;
}

.domig-support-widget__conversation-row:hover {
  background: rgba(255, 255, 255, 0.64);
}

.domig-support-widget__conversation-title {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  font-size: 15px;
  font-weight: 600;
  color: #17312f;
}

.domig-support-widget__conversation-time {
  grid-column: 3;
  grid-row: 1;
  font-size: 12px;
  color: var(--widget-muted);
  justify-self: end;
}

.domig-support-widget__conversation-unread {
  grid-column: 3;
  grid-row: 2;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: var(--widget-primary);
}

.domig-support-widget__thread {
  display: flex;
  flex-direction: column;
}

.domig-support-widget__thread-header {
  min-height: 70px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--widget-line);
  background: rgba(255, 255, 255, 0.94);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.domig-support-widget__thread-header--searching {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.domig-support-widget__thread-title-wrap {
  min-width: 0;
}

.domig-support-widget__thread-title-wrap--public {
  grid-column: 1 / -1;
}

.domig-support-widget__thread-title {
  font-size: 16px;
  font-weight: 700;
  color: #1b3835;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.domig-support-widget__thread-subtitle {
  font-size: 12px;
  color: var(--widget-muted);
  margin-top: 2px;
}

.domig-support-widget__nav-button,
.domig-support-widget__icon-button,
.domig-support-widget__cancel-search,
.domig-support-widget__attachment {
  border: none;
  background: transparent;
  color: var(--widget-icon);
  cursor: pointer;
}

.domig-support-widget__nav-button,
.domig-support-widget__icon-button {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.domig-support-widget__nav-button svg,
.domig-support-widget__icon-button svg,
.domig-support-widget__search-icon svg,
.domig-support-widget__search-nav-button svg {
  width: 18px;
  height: 18px;
}

.domig-support-widget__mobile-close {
  display: none;
}

.domig-support-widget__thread-header-spacer {
  width: 36px;
  height: 36px;
}

.domig-support-widget__search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0 12px;
  height: 38px;
  border-radius: 14px;
  background: #f3f7f6;
  border: 1px solid rgba(16, 67, 60, 0.08);
}

.domig-support-widget__search-icon {
  color: var(--widget-icon);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.domig-support-widget__search-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font: inherit;
  color: #1b3835;
}

.domig-support-widget__search-input:focus,
.domig-support-widget__input:focus {
  outline: none;
}

.domig-support-widget__cancel-search {
  align-self: center;
  font-size: 14px;
  color: #576562;
}

.domig-support-widget__thread-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.domig-support-widget__sticky-day {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  justify-content: center;
  padding: 6px 0;
  margin: 0 0 6px;
  pointer-events: none;
}

.domig-support-widget__sticky-day span {
  opacity: 1;
  transition: opacity 0.16s ease;
}

.domig-support-widget__sticky-day.is-fading span {
  opacity: 0;
}

.domig-support-widget__bubble-row.is-search-match .domig-support-widget__bubble {
  box-shadow: 0 0 0 1px rgba(15, 106, 94, 0.16), 0 8px 18px rgba(14, 34, 31, 0.06);
}

.domig-support-widget__bubble-row.is-current-search-match .domig-support-widget__bubble {
  box-shadow: 0 0 0 2px rgba(15, 106, 94, 0.34), 0 14px 24px rgba(14, 34, 31, 0.1);
}

.domig-support-widget__bubble-row {
  display: flex;
}

.domig-support-widget__chat-divider {
  display: flex;
  justify-content: center;
  margin: 8px 0 4px;
}

.domig-support-widget__chat-divider span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(57, 93, 111, 0.08);
  color: #5e7280;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.domig-support-widget__day-divider {
  display: flex;
  justify-content: center;
  margin: 6px 0 2px;
  transition: opacity 0.18s ease;
}

.domig-support-widget__day-divider span,
.domig-support-widget__sticky-day span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--widget-primary-soft);
  border: 1px solid rgba(15, 106, 94, 0.14);
  box-shadow: 0 10px 18px rgba(14, 34, 31, 0.06);
  color: #2f5752;
  font-size: 11px;
  font-weight: 700;
}

.domig-support-widget__bubble-row.is-own {
  justify-content: flex-end;
}

.domig-support-widget__bubble {
  max-width: 84%;
  padding: 7px 9px 6px;
  border-radius: 18px;
  background: #ffffff;
  border: 1px solid rgba(15, 52, 47, 0.06);
  box-shadow: 0 8px 18px rgba(14, 34, 31, 0.06);
  color: #17312f;
}

.domig-support-widget__bubble-row.is-own .domig-support-widget__bubble {
  background: var(--widget-primary);
  color: #fff;
  border-color: transparent;
}

.domig-support-widget__bubble-author {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.76;
  margin-bottom: 3px;
}

.domig-support-widget__message-text {
  font-size: 14px;
  line-height: 1.38;
  white-space: pre-wrap;
  word-break: break-word;
}

.domig-support-widget__bubble-time {
  margin-top: 4px;
  text-align: right;
  font-size: 11px;
  opacity: 0.72;
}

.domig-support-widget__attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 0;
  color: inherit;
  font-size: 13px;
  text-decoration: underline;
}

.domig-support-widget__thread-composer {
  position: relative;
  padding: 10px;
  border-top: 1px solid var(--widget-line);
  background: rgba(255, 255, 255, 0.94);
}

.domig-support-widget__guest-composer {
  width: 100%;
  max-width: 320px;
  padding: 20px 18px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(37, 99, 235, 0.1);
  border-radius: 24px;
  box-shadow: 0 20px 44px rgba(15, 23, 42, 0.08);
}

.domig-support-widget__guest-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.domig-support-widget__guest-form {
  display: grid;
  gap: 12px;
}

.domig-support-widget__guest-input,
.domig-support-widget__guest-textarea {
  width: 100%;
  border: 1px solid rgba(37, 99, 235, 0.16);
  background: #f8fbff;
  border-radius: 16px;
  padding: 12px 14px;
  font: inherit;
  color: #163230;
}

.domig-support-widget__guest-input:focus,
.domig-support-widget__guest-textarea:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.44);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08);
}

.domig-support-widget__guest-textarea {
  min-height: 110px;
  resize: vertical;
}

.domig-support-widget__guest-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.domig-support-widget__guest-button {
  width: 100%;
  min-height: 46px;
  border-radius: 999px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
}

.domig-support-widget__guest-button--primary {
  background: #2563eb;
  color: #fff;
}

.domig-support-widget__guest-button--secondary {
  background: #eff6ff;
  border-color: rgba(37, 99, 235, 0.16);
  color: #1d4ed8;
}

.domig-support-widget--public-guest .domig-support-widget__panel {
  height: 640px;
}

.domig-support-widget__thread--guest-prechat .domig-support-widget__thread-header {
  border-bottom: 1px solid var(--widget-line);
}

.domig-support-widget__composer-input-wrap {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: end;
  padding: 6px 8px;
  border-radius: 18px;
  border: 1px solid rgba(18, 63, 57, 0.08);
  background: #fff;
}

.domig-support-widget__input {
  border: none;
  background: transparent;
  font: inherit;
  color: #163230;
  resize: none;
  overflow-y: auto;
  min-height: 22px;
  max-height: 144px;
  line-height: 1.36;
  padding: 7px 0;
}

.domig-support-widget__send {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 12px;
  background: var(--widget-primary);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.domig-support-widget__send svg {
  width: 18px;
  height: 18px;
}

.domig-support-widget__send:disabled {
  opacity: 0.55;
  cursor: default;
}

.domig-support-widget__composer-foot {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  align-items: center;
}

.domig-support-widget__file-name {
  font-size: 12px;
  color: var(--widget-muted);
}

.domig-support-widget__file-name.is-empty {
  visibility: hidden;
}

.domig-support-widget__file-input {
  display: none;
}

.domig-support-widget__empty {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.86);
  text-align: center;
  color: var(--widget-muted);
  font-size: 14px;
}

.domig-support-widget__search-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px 14px;
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--widget-line);
}

.domig-support-widget__search-nav-label {
  color: var(--widget-muted);
  font-size: 12px;
  font-weight: 600;
}

.domig-support-widget__search-nav-actions {
  display: inline-flex;
  gap: 4px;
}

.domig-support-widget__search-nav-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.domig-support-widget__emoji-picker {
  position: absolute;
  right: 58px;
  bottom: calc(100% + 10px);
  width: 220px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(18, 46, 43, 0.08);
  box-shadow: 0 20px 36px rgba(15, 23, 42, 0.14);
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

.domig-support-widget__emoji-option {
  border: none;
  border-radius: 12px;
  background: #f5f7f8;
  min-height: 34px;
  cursor: pointer;
  font-size: 18px;
}

.domig-support-widget__emoji-option:hover {
  background: #ebf1f0;
}

.hidden {
  display: none !important;
}

@media (max-width: 768px) {
  .domig-support-widget {
    right: max(12px, env(safe-area-inset-right));
    left: auto;
    bottom: max(12px, env(safe-area-inset-bottom));
    width: auto;
  }

  .domig-support-widget__panel {
    position: fixed;
    left: 0;
    right: 0;
    top: max(0px, env(safe-area-inset-top));
    bottom: 0;
    width: auto;
    height: auto;
    min-height: 100dvh;
    border-radius: 24px 24px 0 0;
    transform-origin: center bottom;
  }

  .domig-support-widget.is-open .domig-support-widget__toggle {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.92);
  }

  .domig-support-widget__header--list {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .domig-support-widget__thread-header {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
  }

  .domig-support-widget__mobile-close {
    display: inline-flex;
  }

  .domig-support-widget__thread-composer {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .domig-support-widget__guest-stage {
    padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  }

  .domig-support-widget__conversation-title {
    font-size: 14px;
  }

  .domig-support-widget__bubble {
    max-width: 90%;
  }

  .domig-support-widget__emoji-picker {
    right: 14px;
    width: min(420px, calc(100vw - 28px));
  }

  .domig-support-widget__guest-actions {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .domig-support-widget {
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    width: auto;
  }

  .domig-support-widget__toggle {
    width: 58px;
    height: 58px;
    border-radius: 16px;
  }

  .domig-support-widget__panel {
    left: 0;
    right: 0;
    top: max(0px, env(safe-area-inset-top));
    bottom: 0;
    min-height: 100dvh;
    border-radius: 20px 20px 0 0;
  }

  .domig-support-widget__header {
    padding: 16px 16px 10px;
  }

  .domig-support-widget__headline {
    font-size: 21px;
  }

  .domig-support-widget__thread-header {
    min-height: 64px;
    padding: 12px 14px;
    gap: 10px;
  }

  .domig-support-widget__nav-button--search {
    display: none;
  }

  .domig-support-widget__thread-body {
    padding: 10px 8px;
  }

  .domig-support-widget__bubble {
    max-width: 92%;
  }

  .domig-support-widget__guest-stage {
    padding: 14px;
  }

  .domig-support-widget__guest-composer {
    max-width: none;
    padding: 18px 16px;
    border-radius: 20px;
  }

  .domig-support-widget__composer-input-wrap {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .domig-support-widget__icon-button[data-action="emoji"] {
    display: none;
  }

  .domig-support-widget__emoji-picker {
    right: 8px;
    width: calc(100vw - 32px);
  }
}