/* === Model Picker: toolbar (search + sort + chips) === */
.mp-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #fff;
  /* компенсация возможного padding-top у .modal-body */
  padding: 14px 16px 12px;
  margin: -16px -16px 12px;
  border-bottom: 1px solid #ececec;
  box-shadow: 0 2px 0 #fff, 0 4px 8px -4px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* На случай, если у .modal-body есть padding-top, который оставляет щель — гасим его */
.modal-body:has(> .mp-toolbar) {
  padding-top: 0 !important;
}

.mp-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.mp-search {
  flex: 1 1 200px;
  min-width: 0;
  padding: 10px 14px;
  background: #f6f7f9;
  border: 1px solid #e3e5e8;
  border-radius: 10px;
  color: #1a1a1a;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.mp-search::placeholder { color: #9aa0a6; }
.mp-search:hover  { background: #f1f2f4; }
.mp-search:focus  { background: #fff; border-color: #4a8df0; box-shadow: 0 0 0 3px rgba(74,141,240,0.12); }

.mp-sort {
  padding: 10px 12px;
  background: #f6f7f9;
  border: 1px solid #e3e5e8;
  border-radius: 10px;
  color: #1a1a1a;
  font-size: 13.5px;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}
.mp-sort:hover { background-color: #f1f2f4; }
.mp-sort:focus { border-color: #4a8df0; box-shadow: 0 0 0 3px rgba(74,141,240,0.12); }

.mp-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-content: flex-start;
  align-items: center;
  column-gap: 6px;
  row-gap: 6px;
  /* [2026-05-23] Единый стиль desktop+mobile: 2 ряда видны, остальное — vertical scroll */
  overflow-x: hidden;
  overflow-y: auto;
  max-height: calc((32px * 2) + 6px);
  padding: 2px 12px 4px 0;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: #c8ccd0 #f1f3f5;
}
/* === Обёртка + подсказка-стрелка справа === */
.mp-chips-wrap { position: relative; }
.mp-scroll-hint {
  position: absolute;
  right: -2px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: #5f6368;
  opacity: 0.75;
  animation: mp-bob 1.4s ease-in-out infinite;
  transition: opacity 0.3s;
  z-index: 2;
}
.mp-scroll-hint.is-hidden { opacity: 0; }
.mp-scroll-hint svg { width: 14px; height: 22px; }
body.dark .mp-scroll-hint,
.modal-overlay.dark .mp-scroll-hint { color: #c0c0c0; }
@keyframes mp-bob {
  0%, 100% { transform: translateY(calc(-50% - 3px)); }
  50%      { transform: translateY(calc(-50% + 3px)); }
}
@media (prefers-reduced-motion: reduce) {
  .mp-scroll-hint { animation: none; }
}

.mp-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: 18px;
  background: #f1f3f5;
  border: 1px solid #e3e5e8;
  color: #3c4043;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.mp-chip:hover {
  background: #e6e9ec;
  border-color: #d4d7da;
}
.mp-chip.active {
  background: #e8f0fe;
  border-color: #4a8df0;
  color: #1967d2;
}

.mp-chip-clear {
  /* [2026-05-23] Единый стиль для desktop + mobile — пунктирный chip */
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 0;
  padding: 6px 13px;
  border-radius: 18px;
  background: #f1f3f5;
  border: 1px dashed #c8ccd0;
  color: #5f6368;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.mp-chip-clear:hover {
  background: #e6e9ec;
  border-color: #aab0b6;
  color: #1a1a1a;
}

.mp-empty {
  padding: 28px 12px;
  text-align: center;
  color: #9aa0a6;
  font-size: 14px;
}

.model-item.mp-hidden { display: none !important; }

/* === Тёмная тема (если когда-нибудь включат body.dark или прейдут на dark modal) === */
body.dark .mp-toolbar,
.modal-overlay.dark .mp-toolbar {
  background: #1a1a1a;
  border-bottom-color: #2a2a2a;
}
body.dark .mp-search,
body.dark .mp-sort,
body.dark .mp-chip,
.modal-overlay.dark .mp-search,
.modal-overlay.dark .mp-sort,
.modal-overlay.dark .mp-chip {
  background: #242424;
  border-color: #333;
  color: #e8eaed;
}
body.dark .mp-chip.active,
.modal-overlay.dark .mp-chip.active {
  background: rgba(74,141,240,0.18);
  border-color: rgba(74,141,240,0.55);
  color: #8ab4f8;
}
body.dark .mp-search::placeholder { color: #6b7075; }
body.dark .mp-chip-clear,
.modal-overlay.dark .mp-chip-clear {
  background: #2a2a2a;
  border-color: #4a4a4a;
  color: #c8c8c8;
}
body.dark .mp-chip-clear:hover,
.modal-overlay.dark .mp-chip-clear:hover {
  background: #353535;
  border-color: #5a5a5a;
  color: #fff;
}

/* === Мобильная адаптация === */
@media (max-width: 768px) {
  .mp-toolbar {
    padding: 12px 0 10px;
    gap: 8px;
  }
  .mp-row {
    flex-wrap: nowrap;
  }
  .mp-search {
    flex: 1 1 auto;
    padding: 9px 12px;
    font-size: 13.5px;
  }
  .mp-sort {
    flex: 0 0 auto;
    padding: 9px 28px 9px 10px;
    font-size: 12.5px;
    max-width: 150px;
  }
  .mp-chips { /* десктопные правила покрывают и мобилу */ }
/* WebKit скроллбар: видимый постоянно, со скруглением сверху и снизу */
  .mp-chips::-webkit-scrollbar {
    width: 6px;
    -webkit-appearance: none;
    appearance: none;
  }
  .mp-chips::-webkit-scrollbar-track {
    background: #f1f3f5;
    border-radius: 10px;
    margin: 2px 0;                       /* отступ от верх/низ для красоты */
  }
  .mp-chips::-webkit-scrollbar-thumb {
    background: #c8ccd0;
    border-radius: 10px;                 /* скругление обоих концов */
    min-height: 24px;
  }
  .mp-chips::-webkit-scrollbar-thumb:hover {
    background: #a8acb0;
  }
  body.dark .mp-chips,
  .modal-overlay.dark .mp-chips {
    scrollbar-color: #666 #2a2a2a;
  }
  body.dark .mp-chips::-webkit-scrollbar-track,
  .modal-overlay.dark .mp-chips::-webkit-scrollbar-track {
    background: #2a2a2a;
  }
  body.dark .mp-chips::-webkit-scrollbar-thumb,
  .modal-overlay.dark .mp-chips::-webkit-scrollbar-thumb {
    background: #666;
  }
  body.dark .mp-chips::-webkit-scrollbar-thumb:hover,
  .modal-overlay.dark .mp-chips::-webkit-scrollbar-thumb:hover {
    background: #888;
  }
  .mp-chip { flex: 0 0 auto; }
  .mp-chip-clear {
    /* Mobile: тот же chip-стиль, но в конце ленты через order */
    order: 99;
  }
  /* Разделитель между группами на мобилке убираем — при wrap он лишний */
  .mp-chips .mp-sep { display: none; }
}


/* === Разделитель между группами тегов === */
.mp-sep {
  display: inline-block;
  width: 1px;
  height: 20px;
  background: #d4d7da;
  margin: 0 6px;
  vertical-align: middle;
}
@media (max-width: 768px) {
  .mp-sep { height: 18px; margin: 0 4px; flex: 0 0 1px; }
}
body.dark .mp-sep { background: #444; }


/* === [2026-05-23] JS-driven кастомный thumb (для iOS, где webkit-scrollbar не виден) === */
.mp-chips-wrap { padding-right: 8px; }
.mp-chips { /* перебиваем системный скроллбар нулевой шириной — рисуем свой */ }
.mp-chips::-webkit-scrollbar { width: 0 !important; height: 0 !important; }

.mp-ios-track {
  position: absolute;
  top: 2px;
  bottom: 4px;
  right: 0;
  width: 4px;
  background: #f1f3f5;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s;
  z-index: 1;
}
.mp-ios-thumb {
  position: absolute;
  left: 0;
  right: 0;
  width: 4px;
  background: #c8ccd0;
  border-radius: 4px;
  pointer-events: none;
  min-height: 20px;
  transition: background 0.2s;
}
.mp-chips-wrap.has-overflow .mp-ios-track { opacity: 1; }
body.dark .mp-ios-track,
.modal-overlay.dark .mp-ios-track { background: #2a2a2a; }
body.dark .mp-ios-thumb,
.modal-overlay.dark .mp-ios-thumb { background: #666; }

/* [2026-05-23] Скрываем подсказку-стрелку — теперь её роль выполняет видимый thumb */
.mp-scroll-hint { display: none !important; }

/* [2026-05-23] Финал: убиваем нативный scrollbar у .mp-chips — оставляем только кастомный thumb */
.mp-chips {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}
.mp-chips::-webkit-scrollbar,
.mp-chips::-webkit-scrollbar-track,
.mp-chips::-webkit-scrollbar-thumb {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  background: transparent !important;
}


/* === [2026-05-23] Иконки в кнопках выбора (sidebar + header pills) === */
.btn-assistant-select .btn-icon,
.btn-vector-select .btn-icon,
.btn-menu-select .btn-icon,
.header-pill-link .btn-icon {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  margin-right: 6px;
  flex-shrink: 0;
  display: inline-block;
}
.btn-assistant-select,
.btn-vector-select,
.btn-menu-select,
.header-pill-link {
  display: inline-flex;
  align-items: center;
}
