/* Search field opens a surface: recent queries as a list, scope as a token. */

.wh-qs {
    position: absolute;
    z-index: 10050;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    min-width: 220px;
    padding: 6px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(22px) saturate(1.35);
    -webkit-backdrop-filter: blur(22px) saturate(1.35);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow:
        0 1px 1px rgba(15, 17, 23, 0.04),
        0 16px 40px rgba(15, 17, 23, 0.14);
    color: #0e121b;
    text-align: left;
    transform-origin: top center;
}

.wh-qs[hidden] {
    display: none !important;
}

.wh-qs.is-open {
    animation: wh-qs-in 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes wh-qs-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.wh-qs-label {
    padding: 6px 10px 2px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #8b93a7;
}

.wh-qs-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 36px;
    margin: 0;
    padding: 0 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.01em;
    text-align: left;
    cursor: pointer;
}

.wh-qs-row svg {
    flex: 0 0 auto;
    color: #8b93a7;
}

.wh-qs-row span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wh-qs-row:hover,
.wh-qs-row.is-active {
    background: rgba(14, 18, 27, 0.05);
}

.wh-qs-empty {
    padding: 8px 10px 10px;
    font-size: 13px;
    line-height: 1.4;
    color: #8b93a7;
}

.wh-qs-token {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
    height: 24px;
    margin-left: 4px;
    padding: 0 8px 0 10px;
    border-radius: 999px;
    border: 1px solid rgba(14, 18, 27, 0.1);
    background: rgba(14, 18, 27, 0.04);
    color: #3e4c63;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: -0.01em;
    cursor: pointer;
    white-space: nowrap;
}

.wh-qs-token:hover,
.wh-qs-token[aria-expanded="true"] {
    background: rgba(14, 18, 27, 0.08);
    color: #0e121b;
}

.wh-qs-token svg {
    flex: 0 0 auto;
    opacity: 0.7;
}

.wh-qs-scope {
    position: fixed;
    z-index: 10060;
    min-width: 168px;
    padding: 6px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(22px) saturate(1.35);
    -webkit-backdrop-filter: blur(22px) saturate(1.35);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow:
        0 1px 1px rgba(15, 17, 23, 0.04),
        0 16px 40px rgba(15, 17, 23, 0.16);
}

.wh-qs-scope[hidden] {
    display: none !important;
}

.wh-qs-scope-label {
    padding: 6px 10px 2px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #8b93a7;
}

.wh-qs-scope button {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 32px;
    padding: 0 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #0e121b;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}

.wh-qs-scope button:hover,
.wh-qs-scope button.is-active {
    background: rgba(14, 18, 27, 0.05);
}

.wh-qs-scope button[aria-selected="true"] {
    font-weight: 600;
}

.select-wrapper.wh-qs-scope-retired {
    display: none !important;
}

/* Ad library: the open field and the list are one surface. */
.ads-page-wrapper .ads-topbar-search .relative.z-10.isolate:has(#suggested-searches:not(.hidden)) .keyword-search-inset,
.ads-page-wrapper #ads-topbar-search-slot .relative.z-10.isolate:has(#suggested-searches:not(.hidden)) .keyword-search-inset {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

.ads-page-wrapper .ads-topbar-search #suggested-searches:not(.hidden),
.ads-page-wrapper #ads-topbar-search-slot #suggested-searches:not(.hidden) {
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    border-radius: 16px !important;
    border: 1px solid rgba(14, 18, 27, 0.08) !important;
    box-shadow:
        0 1px 1px rgba(15, 17, 23, 0.04),
        0 18px 44px rgba(15, 17, 23, 0.16) !important;
    padding-top: calc(var(--keyword-search-bar-min-h, 2.5rem) + 0.35rem) !important;
}

.ads-page-wrapper .ads-topbar-search .relative.z-10.isolate:has(#suggested-searches:not(.hidden)) #keyword-composite,
.ads-page-wrapper #ads-topbar-search-slot .relative.z-10.isolate:has(#suggested-searches:not(.hidden)) #keyword-composite {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

.ads-page-wrapper .ads-topbar-search #suggested-searches:not(.hidden)::before,
.ads-page-wrapper #ads-topbar-search-slot #suggested-searches:not(.hidden)::before {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    top: var(--keyword-search-bar-min-h, 2.5rem);
    height: 1px;
    background: rgba(14, 18, 27, 0.08);
    pointer-events: none;
}

html[data-theme="dark"] .ads-page-wrapper .ads-topbar-search #suggested-searches:not(.hidden),
html[data-theme="dark"] .ads-page-wrapper #ads-topbar-search-slot #suggested-searches:not(.hidden) {
    border-color: rgba(255, 255, 255, 0.08) !important;
}

html[data-theme="dark"] .ads-page-wrapper .ads-topbar-search #suggested-searches:not(.hidden)::before,
html[data-theme="dark"] .ads-page-wrapper #ads-topbar-search-slot #suggested-searches:not(.hidden)::before {
    background: rgba(255, 255, 255, 0.08);
}

/* Ad library recents: the existing chip row becomes a list under the field. */
#suggested-searches > .w-full.flex.flex-col.gap-1 > .relative.w-full.flex {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 2px !important;
}

#suggested-searches .flex-grow.flex.items-center.overflow-x-auto,
#suggested-searches .scrollbar-hidden.flex-grow {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    overflow: hidden !important;
    max-height: 320px;
    width: 100%;
    gap: 2px !important;
}

#suggested-searches button[data-search-scope][aria-selected="true"] {
    background: rgba(14, 18, 27, 0.06);
}

#suggested-searches .scroll-nav-btn,
#suggested-searches .rs-right-fade-overlay {
    display: none !important;
}

#suggested-searches .text-gray-650 {
    padding: 4px 8px 2px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #8b93a7 !important;
}

#suggested-searches .recent-search {
    display: flex !important;
    align-items: center;
    width: 100% !important;
    min-height: 36px;
    padding: 0 8px !important;
    border-radius: 10px !important;
    background: transparent !important;
    gap: 8px;
}

#suggested-searches .recent-search::before {
    content: "";
    flex: 0 0 auto;
    width: 14px;
    height: 14px;
    background: #8b93a7;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='9'/><path d='M12 7v5l3 2'/></svg>") center / contain no-repeat;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='9'/><path d='M12 7v5l3 2'/></svg>") center / contain no-repeat;
}

#suggested-searches .recent-search:hover {
    background: rgba(14, 18, 27, 0.05) !important;
}

#suggested-searches .recent-search:hover div,
#suggested-searches .recent-search div {
    color: #0e121b !important;
    font-size: 14px !important;
    font-weight: 500 !important;
}

#suggested-searches .recent-search .remove-button {
    margin-left: auto;
    color: #8b93a7;
}

#suggested-searches .wh-qs-label,
#suggested-searches .wh-qs-empty {
    text-align: left;
}

html[data-theme="dark"] .wh-qs,
html[data-theme="dark"] .wh-qs-scope {
    background: rgba(28, 30, 36, 0.94);
    border-color: rgba(255, 255, 255, 0.08);
    color: #f4f6f8;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .wh-qs-row:hover,
html[data-theme="dark"] .wh-qs-row.is-active,
html[data-theme="dark"] .wh-qs-scope button:hover,
html[data-theme="dark"] .wh-qs-scope button.is-active {
    background: rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .wh-qs-token {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: #d5dbe6;
}

html[data-theme="dark"] .wh-qs-token:hover,
html[data-theme="dark"] .wh-qs-token[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

html[data-theme="dark"] #suggested-searches .recent-search:hover,
html[data-theme="dark"] #suggested-searches button[data-search-scope][aria-selected="true"] {
    background: rgba(255, 255, 255, 0.08) !important;
}

html[data-theme="dark"] #suggested-searches .recent-search:hover div,
html[data-theme="dark"] #suggested-searches .recent-search div {
    color: #f4f6f8 !important;
}

@media (prefers-reduced-motion: reduce) {
    .wh-qs.is-open {
        animation: none;
    }
}
