.search-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #fff; /* Или любой другой фон */
    z-index: 1001; /* Чтобы был поверх всего */
    display: none; /* Скрыт по умолчанию */
    flex-direction: column;
    padding: 1rem;
    overflow-y: auto; /* Добавляем прокрутку, если контент не помещается */
}

.search-sidebar.show {
    display: flex; /* Показываем при добавлении класса .show */
}

.search-sidebar-header {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}

.search-sidebar-header i {
    margin-right: 0.5rem;
    cursor: pointer;
    font-size: 24px;
    color: #222;
}

.search-sidebar-header input {
    flex-grow: 1;
    padding: 0.5rem;
    border: 1px solid #ccc;
}

.search-sidebar-header a.search-cancel {
    margin-left: 0.5rem;
    text-decoration: none;
    color: #555;
}

.search-history {
    margin-bottom: 1rem;
}

.search-history-items {
    display: flex;
    flex-wrap: wrap;
}

.search-history-items a {
    display: block;
    padding: 0.5rem 1rem;
    background-color: #f0f0f0;
    margin: 0.25rem;
    border-radius: 5px;
    text-decoration: none;
    color: #333;
}

.search-history-items a .remove-history-item {
    margin-left: 0.5rem;
    cursor: pointer;
    font-size: 20px;
}

.search-results {
    margin-bottom: 1rem;
}

.may-interest {
    margin-bottom: 1rem;
}

.categories {
    margin-bottom: 1rem;
}

/* CSS: компактное (collapsed) состояние для .search-history-items */
.search-history-items {
    transition: max-height .18s ease, font-size .18s ease, padding .18s ease;
    max-height: 12rem; /* обычный развернутый максимум */
    overflow: visible;
    font-size: 1rem;
    padding: 0.5rem 0;
    box-sizing: border-box;
}

/* Свёрнутое состояние — занимает минимум места, чтобы результаты поиска были видны */
.search-history-items.collapsed-history {
    max-height: 3.2rem;
    font-size: 0.88rem;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    padding: 0.25rem 0;
    display: block;
    -webkit-overflow-scrolling: touch; /* плавный скролл на мобильных */
}

/* Элементы истории в виде компактных "чипов" */
.search-history-items.collapsed-history a {
    display: inline-block;
    margin-right: 0.5rem;
    padding: 0.32rem 0.6rem;
    border-radius: 999px;
    background-color: rgba(0, 0, 0, 0.04);
    color: inherit;
    text-decoration: none;
    vertical-align: middle;
    white-space: nowrap;
}

/* Иконка удаления в чипе — компактнее, чтобы не занимать много места */
.search-history-items.collapsed-history a .remove-history-item {
    margin-left: 0.45rem;
    opacity: 0.9;
    font-size: 0.85em;
}

/* Тонкий горизонтальный скролл для webkit-браузеров */
.search-history-items.collapsed-history::-webkit-scrollbar {
    height: 6px;
}
.search-history-items.collapsed-history::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 3px;
}
.search-history-items.collapsed-history::-webkit-scrollbar-track {
    background: transparent;
}

/* Небольшие корректировки для очень маленьких экранов */
@media (max-width: 480px) {
    .search-history-items.collapsed-history {
        max-height: 2.6rem;
        font-size: 0.82rem;
    }
    .search-history-items.collapsed-history a {
        padding: 0.28rem 0.5rem;
    }
}