:root {
    --agg-buckets-bg: linear-gradient(180deg, rgba(250,252,255,0.96), rgba(246,251,255,0.98));
    --agg-buckets-border: rgba(207,231,255,0.6);
    --agg-bucket-bg: #ffffff;
    --agg-bucket-border: rgba(16,35,60,0.04);
    --agg-bucket-hover: #eef8ff;
    --agg-bucket-selected-bg: #f0f8ff;
    --agg-bucket-selected-border: rgba(0,123,255,0.14);
    --agg-bucket-text: #10233b;
    --agg-bucket-muted: #6b6b6b;
    --agg-bucket-shadow: 0 8px 20px rgba(14,30,60,0.03);
    --agg-outline: 3px solid rgba(15,85,255,0.12);
}

.main .adv-search-menu a::before {
    content: "\f00e";
}

.aggregation {
    position: relative;
    margin: 0px;
    padding: 0;
    list-style: none;
    overflow: visible;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(14,30,60,0.03);
    border: 1px solid transparent;
    display: inline-block;
    width: auto;
}

.aggregation-name {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 14px;
    cursor: pointer;
    font-weight: 600;
    color: #10233b;
    background: linear-gradient(180deg, #fbfdff, #f6fbff);
    border: 1px solid #cfe7ff;
    width: auto;
    min-width: 0;
    border-radius: 14px;
}

.aggregation-name.aggregation-selected {
    background: rgba(0,123,255,0.08);
    border: 1px solid rgba(0,123,255,0.16);
}

.aggregation-name.aggregation-selected .aggregation-toggle {
    color: #004a99;
    font-weight: 700;
}

.aggregation-toggle {
    display: inline-block;
    width: 100%;
    color: inherit;
    text-decoration: none;
    background: transparent;
    border: 0;
    padding: 0;
    font: inherit;
    line-height: 1;
}

.aggregation-name .aggregation-toggle::after {
    content: "▸";
    display: inline-block;
    margin-left: 10px;
    transform: rotate(0deg);
    transition: transform 220ms ease, color 220ms ease;
    color: #6b6b6b;
    font-size: 12px;
}

.aggregation-name.open .aggregation-toggle::after {
    transform: rotate(90deg);
    color: #007bff;
}

.aggregation-buckets-container {
    margin: 0;
    padding: 0;
    position: absolute;
    left: 0;
    top: 100%;
    width: max-content;
    min-width: 100%;
    z-index: 1200;
}

.aggregation-buckets {
    margin: 0;
    padding: 12px;
    display: none;
    background: transparent;
    border-top: 0;
    min-width: max-content;

    transform-origin: top;
    transition: transform 160ms ease, opacity 160ms ease;
    background: var(--agg-buckets-bg);
    border: 1px solid var(--agg-buckets-border);
    border-radius: 12px;
    box-shadow: var(--agg-bucket-shadow);
}

.aggregation-buckets-container.open .aggregation-buckets {
    display: block;
}

.aggregation-value {
    list-style: none;
    margin: 6px 0;
    padding: 0;
    transition: background-color 140ms ease, color 140ms ease, transform 120ms ease;
    border-radius: 10px;
    background: var(--agg-bucket-bg);
    border: 1px solid var(--agg-bucket-border);
    color: var(--agg-bucket-text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.aggregation-value a {
    color: inherit;
    text-decoration: none;
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
}

.aggregation-value a:focus-visible {
    outline: var(--agg-outline);
    outline-offset: 3px;
    border-radius: 8px;
}

.aggregation-value:hover,
.aggregation-value:focus-within {
    background: var(--agg-bucket-hover);
    border-color: var(--agg-outline);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(14,30,60,0.04);
}

.aggregation-value.aggregation-selected {
    background: var(--agg-bucket-selected-bg);
    border: 1px solid var(--agg-bucket-selected-border);
    color: var(--agg-bucket-text);
    font-weight: 600;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
}

.aggregation-value.aggregation-selected a {
    color: #0056b3;
    font-weight: 600;
}

.aggregation-bucket-count {
    display: inline-block;
    vertical-align: middle;
    color: var(--agg-bucket-muted);
    font-size: 90%;
    margin-left: 8px;
    background: rgba(16,35,60,0.04);
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid rgba(16,35,60,0.03);
}

.aggregation.compact .aggregation-name { padding: 8px 10px; }
.aggregation.compact .aggregation-buckets { padding: 6px; }
.aggregation.compact .aggregation-value { padding: 6px 8px; font-size: 13px; }

.aggregation-selected-container {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 10px;
}

.aggregation-selected-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(0,123,255,0.08);
    color: #004a99;
    border: 1px solid rgba(0,123,255,0.12);
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    line-height: 1;
    transition: background-color 160ms ease, transform 120ms ease, color 120ms ease, box-shadow 120ms ease;
    white-space: nowrap;
}

.aggregation-selected-pill::after {
    content: "\00D7";
    display: inline-block;
    margin-left: 6px;
    font-size: 12px;
    line-height: 1;
    color: inherit;
    opacity: 0.95;
    transform: translateY(-1px);
    pointer-events: none;
}

.aggregation-selected-pill:hover {
    background: rgba(0,123,255,0.14);
    color: #003770;
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(0,123,255,0.04);
}

.aggregation-name.aggregation-selected .aggregation-selected-pill {
    background: rgba(0,123,255,0.12);
    color: #004a99;
    border-color: rgba(0,123,255,0.24);
}

.aggregation.compact .aggregation-selected-container { gap: 6px; margin-left: 8px; }
.aggregation.compact .aggregation-selected-pill { padding: 4px 8px; font-size: 12px; }

.aggregation-name { gap: 8px; display: inline-flex; align-items: center; }

@media (max-width: 520px) {
    .aggregation-name { padding: 10px; font-size: 15px; }
    .aggregation-buckets-container {
        position: static;
        width: 100%;
        box-shadow: none;
        border-radius: 8px;
    }
    .aggregation-buckets { display: block; padding-left: 10px; padding-right: 10px; }
    .aggregation-value { margin: 6px 0; }
}