.af-header,
.af-header > .max-w-6xl {
    overflow: visible;
}

.af-header-search {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 36rem;
    margin: 0 0.25rem;
    z-index: 60;
}

.af-header-search-form {
    display: flex;
    align-items: stretch;
    width: 100%;
    border: 1px solid var(--af-border);
    border-radius: 0.75rem;
    background: var(--af-surface);
    overflow: hidden;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.af-header-search-form:focus-within {
    border-color: var(--af-accent);
    box-shadow: 0 0 0 3px var(--af-accent-soft);
}

.af-header-search-input {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--af-text);
    font-size: 0.9375rem;
    line-height: 1.25;
    padding: 0.55rem 0.85rem;
    outline: none;
}

.af-header-search-input::placeholder {
    color: var(--af-text-muted);
}

.af-header-search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

.af-header-search-dropdown {
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 0;
    right: 0;
    z-index: 80;
    display: flex;
    flex-direction: column;
    max-height: min(70vh, 32rem);
    overflow: hidden;
    border: 1px solid var(--af-border);
    border-radius: 0.9rem;
    background: var(--af-surface);
    box-shadow: var(--af-shadow-lg);
}

/* display:flex above would otherwise override the UA [hidden] { display:none } */
.af-header-search-dropdown[hidden] {
    display: none !important;
}

.af-header-search-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.af-header-search-section {
    padding: 0.65rem 0 0.25rem;
}

.af-header-search-section + .af-header-search-section {
    border-top: 1px solid var(--af-border);
}

.af-header-search-section-title {
    padding: 0 0.9rem 0.4rem;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--af-accent);
}

.af-header-search-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.9rem;
    color: var(--af-text);
    text-decoration: none;
    transition: background 0.12s ease;
}

.af-header-search-item:hover,
.af-header-search-item.is-active {
    background: var(--af-accent-soft);
}

.af-header-search-item-text {
    min-width: 0;
    flex: 1;
}

.af-header-search-item-title {
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.3;
}

.af-header-search-item-meta {
    margin-top: 0.15rem;
    font-size: 0.8125rem;
    color: var(--af-text-muted);
    line-height: 1.3;
}

.af-header-search-item-genre {
    margin-top: 0.2rem;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0;
    color: var(--af-text-muted);
}

.af-header-search-cover {
    width: 2.5rem;
    height: 3.5rem;
    object-fit: cover;
    border-radius: 0.35rem;
    background: var(--af-border);
    flex-shrink: 0;
}

.af-header-search-cover--empty {
    display: block;
}

.af-header-search-dropdown mark {
    background: var(--af-accent-soft);
    color: inherit;
    border-radius: 0.15rem;
    padding: 0 0.05em;
}

.af-header-search-footer {
    flex: 0 0 auto;
    padding: 0.65rem 0.9rem 0.85rem;
    border-top: 1px solid var(--af-border);
    background: var(--af-surface);
}

.af-header-search-all {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 2.5rem;
    padding: 0.55rem 1rem;
    border-radius: 0.65rem;
    background: var(--af-dark);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.15s ease;
}

.af-header-search-all:hover {
    opacity: 0.92;
    color: #fff;
}

.af-header-search-empty {
    padding: 1rem 0.9rem;
    font-size: 0.875rem;
    color: var(--af-text-muted);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 639px) {
    .af-header-search {
        max-width: none;
        margin: 0;
        order: 3;
        flex: 1 1 100%;
    }

    .af-header > .max-w-6xl {
        flex-wrap: wrap;
        overflow: visible;
    }

    .af-header-search-dropdown {
        position: absolute;
        left: 0;
        right: 0;
        width: auto;
        max-height: min(60vh, 28rem);
    }
}

.dark .af-header-search-all {
    background: #334155;
}
